I’m seeing a difference in dynamic inventory between 1.9.4 and 2.0 but what we have seems to be correct according to the documentation.
Here is a simple Shell script to demonstrate:
#!/bin/sh
cat <<!
{
“fooservers”: {
“children”: [ “fooA”, “fooB” ]
},
“fooA”: [ “host1” ],
“fooB”: [ “host2” ]
}
!
If I put this in a directory as inventory/test.sh then I see the following:
With Ansible 1.9.4:
$ ansible --version
ansible 1.9.4
configured module search path = None
$ ansible --list-hosts -i inventory fooservers
host1
host2
With Ansible 2.0:
$ ansible --version
ansible 2.0.0.2
config file = /var/tmp/playbook/ansible.cfg
configured module search path = Default w/o overrides
$ ansible --list-hosts -i inventory fooservers
hosts (1):
fooservers
It looks like in 2.0 the group of groups isn’t getting expanded. Did the syntax of how children get specified change in 2.0?
I discovered that if I add an empty hosts or vars then it works:
#!/bin/sh
cat <<!
{
“fooservers”: {
“hosts”: ,
“children”: [ “fooA”, “fooB” ]
},
“fooA”: [ “host1” ],
“fooB”: [ “host2” ]
}
!
$ ansible -i inventory --list-hosts fooservers
hosts (2):
host1
host2
– Bruce