Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAML Inventory Parsing Issue #41692

Closed
riglersc opened this issue Jun 19, 2018 · 2 comments · Fixed by #41698
Closed

YAML Inventory Parsing Issue #41692

riglersc opened this issue Jun 19, 2018 · 2 comments · Fixed by #41698
Labels
bug This issue/PR relates to a bug. P2 Priority 2 - Issue Blocks Release support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Milestone

Comments

@riglersc
Copy link

riglersc commented Jun 19, 2018

SUMMARY

In Ansible 2.6 RC3 we are seeing an issue where the YAML inventory parser is not correctly identifying groups. Eg, for this inventory file:

---
group1:
  children:
    group2:

group2:
  hosts:
    host1:
    host2:

Running "ansible group1 --list-hosts" complains about "group2":

 [WARNING]: Skipping 'group2' as this is not a valid group definition

 [WARNING]: No hosts matched, nothing to do

  hosts (0):
ISSUE TYPE
  • Bug Report
COMPONENT NAME
ANSIBLE VERSION
ansible 2.6.0rc3
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible
  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]

CONFIGURATION
DEFAULT_HOST_LIST(/etc/ansible/ansible.cfg) = [u'/etc/ansible/hosts.yml']
OS / ENVIRONMENT

CentOS Linux release 7.4.1708 (Core)

STEPS TO REPRODUCE
# cat hosts.yml
---
group1:
  children:
    group2:

group2:
  hosts:
    host1:
    host2:

EXPECTED RESULTS

With Ansible 2.4 and 2.5 we get these results:

# ansible group1 --list-hosts
  hosts (2):
    host2
    host1
ACTUAL RESULTS

With ansible 2.6 we get these results:

# ansible group1 --list-hosts -vvv
ansible 2.6.0rc3
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible
  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
Using /etc/ansible/ansible.cfg as config file
 [WARNING]: Skipping 'group2' as this is not a valid group definition

Parsed /etc/ansible/hosts.yml inventory source with ini plugin
 [WARNING]: No hosts matched, nothing to do

  hosts (0):

@ansibot ansibot added affects_2.6 This issue/PR affects Ansible v2.6 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Jun 19, 2018
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Jun 19, 2018
@bcoca bcoca added this to the 2.6.0 milestone Jun 19, 2018
@bcoca bcoca added P2 Priority 2 - Issue Blocks Release and removed affects_2.6 This issue/PR affects Ansible v2.6 labels Jun 19, 2018
@bcoca
Copy link
Member

bcoca commented Jun 19, 2018

with patch from PR above I now get:

  hosts (2):
    host2
    host1

@riglersc
Copy link
Author

@bcoca I applied the patch and it works as advertised. Thanks for the quick fix!

bcoca added a commit to bcoca/ansible that referenced this issue Jun 19, 2018
 - even if defined as mapping but having no keys, objects shoudl still be processed correctly
 - also add ansilbe_verbosity to vars not to display in ansible-inventory

fixes ansible#41692
bcoca added a commit to bcoca/ansible that referenced this issue Jun 20, 2018
* handle groups correctly when they are 'null'

 - even if defined as mapping but having no keys, objects shoudl still be processed correctly
 - also add ansilbe_verbosity to vars not to display in ansible-inventory

fixes ansible#41692

(cherry picked from commit 05a49d6)
bcoca added a commit that referenced this issue Jun 20, 2018
* handle groups correctly when they are 'null'

 - even if defined as mapping but having no keys, objects shoudl still be processed correctly
 - also add ansilbe_verbosity to vars not to display in ansible-inventory

fixes #41692
mattclay pushed a commit that referenced this issue Jun 21, 2018
* handle groups correctly when they are 'null'

 - even if defined as mapping but having no keys, objects shoudl still be processed correctly
 - also add ansilbe_verbosity to vars not to display in ansible-inventory

fixes #41692

(cherry picked from commit 05a49d6)
jacum pushed a commit to jacum/ansible that referenced this issue Jun 26, 2018
* handle groups correctly when they are 'null'

 - even if defined as mapping but having no keys, objects shoudl still be processed correctly
 - also add ansilbe_verbosity to vars not to display in ansible-inventory

fixes ansible#41692
kbreit pushed a commit to kbreit/ansible that referenced this issue Jul 3, 2018
* handle groups correctly when they are 'null'

 - even if defined as mapping but having no keys, objects shoudl still be processed correctly
 - also add ansilbe_verbosity to vars not to display in ansible-inventory

fixes ansible#41692

(cherry picked from commit 05a49d6)
@ansible ansible locked and limited conversation to collaborators Jun 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug. P2 Priority 2 - Issue Blocks Release support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants