Inventory issue

Hi guys,

I’m facing with an issue and I cannot find the reason for this behaviour of ansible:
My hosts file (part of it):

[lb]
lb[1:2]

lb3

The result in command line:

ansible -a whoami lb
lb1 | success | rc=0 >>
root

lb2 | success | rc=0 >>
root

lb3 | success | rc=0 >>
root

In my opinion the above command should check only lb1 and lb2, as lb3 is not the part of the lb group.
Can anyone tell me why it’s catching the 3rd lb node?
Strange thing is if I’m removing the lb3 from it’s current place in the hosts file and placing it somewhere else, then the issue is gone, for example:

[lb]
lb[1:2]

[payment]
payment[1:3]

lb3

I think parsing the hosts file is wrong in ansible in this case.
Thanks.

Hi,

it is because lb3 is in lb group. Group ends when new group start, in your second case lb3 is in payment group.

For lb3 to be in all group only it must be defined before any group is started.

David

Dne 15. 10. 2015 18:50 napsal uživatel <gabor.debreczeni@privax.com>:

Hello,

if you don’t want to put lb3 in a group you would need this:

lb3
[lb]
lb[1:2]

A blank line doesn’t separate anything. In your second example lb3 is in the payment group.
http://docs.ansible.com/ansible/intro_inventory.html

https://en.wikipedia.org/wiki/INI_file

esco

Thank you guys, I moved now all standalone hosts to the front of the inventory file (before the group definitions) and the issue is gone.