Dynamic Inventory in 2.0 with children

29 views
Skip to first unread message

Bruce Freeman

unread,
Feb 20, 2016, 2:45:21 PM2/20/16
to Ansible Project
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

Brian Coca

unread,
Feb 20, 2016, 2:48:43 PM2/20/16
to ansible...@googlegroups.com
​It seems you found a bug...​

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0bd5c192-f120-4c60-a7b4-c43dac858881%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages