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

BUGFIX : using yaml hosts inventory, hosts in groups weren't added to… #23366

Merged
merged 1 commit into from
Apr 7, 2017

Conversation

pae23
Copy link

@pae23 pae23 commented Apr 6, 2017

… the group 'all'

SUMMARY

fix "auto adding" to group "all" of hosts in groups using YAML inventory. (not listed as issue)

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME
ANSIBLE VERSION

tested on 2.3 and devel

ADDITIONAL INFORMATION

The problem is present at least in branches stable-2.3 too (and should be backported).

You can test using an host.yml file like :

test:
  hosts:
    192.168.1.1:
    192.168.1.2:

@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 bugfix_pull_request needs_triage Needs a first human triage before being processed. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Apr 6, 2017
@bcoca bcoca removed the needs_triage Needs a first human triage before being processed. label Apr 7, 2017
@bcoca
Copy link
Member

bcoca commented Apr 7, 2017

also fixed in passing in #23001

@bcoca
Copy link
Member

bcoca commented Apr 7, 2017

also, if you follow the example https://github.com/ansible/ansible/blob/devel/examples/hosts.yaml
you start with group 'all' at the top level, which makes all the hosts be part of that group.

@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Apr 7, 2017
@pae23
Copy link
Author

pae23 commented Apr 7, 2017

I understand it's becoming as plugins in devel branch, but for <= 2.3, this is a bug : the comment at line 69 of lib/ansible/inventory/yaml.py is explicit :

        # Finally, add all top-level groups as children of 'all'.
        # We exclude ungrouped here because it was already added as a child of
        # 'all' at the time it was created.

and on that link : https://github.com/ansible/ansible/search?utf8=%E2%9C%93&q=%22self.groups%5B%27all%27%5D.add_child_group%22&type=
we can see that the yaml implementaion is the only one affected by this bug.

@bcoca
Copy link
Member

bcoca commented Apr 7, 2017

both patches are needed, other inventory sources can do same

@bcoca bcoca merged commit 283a884 into ansible:devel Apr 7, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bugfix_pull_request labels Mar 6, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants