-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
hosts defined in two groups in different inventory files each is used multiple times #5749
Comments
Per contributing.md can you please provide your ansible version? ( If I remember correctly, this has been resolved in devel (1.5) |
Yes, this was resolved by 559e890 Please rebase and try again if you are running an older version. |
@sivel: amended the report |
@g-k-r this is resolved in devel, and will be in the 1.5 release. |
@jctanner: tested with devel, not solved, will provide unit test in PR based on devel |
tests issue ansible#5749 same host defined in different groups which in turn are defined in different ini files in an inventory directory
Reopening for testing. |
@g-k-r unable to reproduce ...
|
@g-k-r how do you install ansible and how are you using the checkout to verify devel's behavior? |
I do the following: git clone https://github.com/g-k-r/ansible.git
. ./hacking/env-setup
ansible --version
make tests or instead of PYTHONPATH=./lib ANSIBLE_LIBRARY=./library nosetests -d -v test/TestInventory.py:TestInventory.test_dir_inventory_multiple_groups what is strange, is that testing with the original reproduction tests from the first post on this issue do work as you say, while the test started by nosetests doesn't.
|
that is confusing, calling ansible directly succeeds:
what doesn't work anymore is:
with ansible 1.4.4 this results in:
|
tests issue ansible#5749 same host defined in different groups which in turn are defined in different ini files in an inventory directory
sorry about the many commits, i changed the test which now works identical to direct ansible calls, will now create a pull request, if you want to add the test to the code. thanks! |
@g-k-r i think you are mixing up installed ansible lib paths with the checkout lib paths. Can you please retest on a clean machine with a fresh checkout and no ansible packages installed? |
ok i will test in a cleanrooom VM, hopefully tonight otherwise this needs to wait until the week after next |
hi @jctanner i tested in a clean debian wheezy to test the initial implementation with get_group i had to checkout the second commit in my pull request. since the latest commit overwrites the test implementation to use get_hosts instead of get_group.
inventory.get_group is not behaving like i though it should. anyway the get_hosts version (HEAD of the pull request) works. |
It looks like there isn't any outstanding issues with this ticket so I am going to close it out based on your final comment here. I don't see the duplication that you are pointing out in the recent branches. If you are continuing to see problems feel free to ping me @ansible.com and we can sort it out. |
This sounds like this comment was about a pull request that wasn't applied yet so I'm reopening this one for now, unless we can't reproduce this on head, etc. |
ok beat me to it, thanks! |
tests issue ansible#5749 same host defined in different groups which in turn are defined in different ini files in an inventory directory Conflicts: test/units/TestInventory.py
closes ansible#5749 Conflicts: test/units/TestInventory.py
Pertaining to the original description of this thread as of 1.5 this is fixed and tests correct. After comment 11 you have a few commits that end up being a part of GH-5837. We have made some changes around I cherry picked the changes off into a branch that I am working on un-commenting test_dir_inventory. Your test should be merged as a part of GH-6287. In which you will get credit for the test code. This issue has wondered a bit but from what I can see there is one remaining question. That question is: Should get_groups return multiple entries? The answer to this looks to be that based on how it is used internally in inventory/init.py that there is a level of reduplication that ends up happening so it isn’t an issue unless you are calling it directly. So once my PR goes in it will pull in your PR. I hope that I have shed a little bit of light on this. |
Fix inventory for test_dir_inventory, merge PRs from GH-5749, cleanup some formatting.
@risaacson thanks, information round up appreciated |
tests issue ansible#5749 same host defined in different groups which in turn are defined in different ini files in an inventory directory Conflicts: test/units/TestInventory.py
closes ansible#5749 Conflicts: test/units/TestInventory.py
Post merging of ansibleGH-5837 via ansibleGH-5749.
when using multiple inventory files defining different groups for the same hosts, ansible adds the hosts multiple times to the inventory list.
version: 1.4.4+dfsg-1 (from debian jessie)
same problem with current devel 00b3f62
reproduce:
actual output:
note when the group is defined in both files like [type1] this does not happen.
expected output: www.yahoo.com shows up once only i.e.
additional information:
to verify that tasks would actually be executed multiple times use
The text was updated successfully, but these errors were encountered: