dynamic inventory and --list printing the groupname

378 views
Skip to first unread message

habeeb rahman

unread,
Feb 9, 2014, 2:33:39 PM2/9/14
to ansible...@googlegroups.com
Hi Ansiblers,

I just finished a python program to query our mysql inventory.
when I do python getinv.py --list, i can see the json output. And 'ansible us-east-1_app1 --list-hosts' works as well.
The only problem is it also displays the group name in the output. This affects when I check say uptime - ssh says not able to ssh to the group name.
eg,
$>ansible us-east-1_app1 --list-hosts
    us-east-1_app1
    app000ea2
    app002ea1

Any idea why ansible also gets the group name?
Here is the json part...

    "us-east-1_app1": {
        "children": [
            "app1"
        ]
    },

    "app1": {
        "hosts": [
            "app000ea1",
            "app002ea2"
        ]
    },

Any pointers?

Michael DeHaan

unread,
Feb 9, 2014, 4:19:03 PM2/9/14
to ansible...@googlegroups.com
Can you please show the full output from the list command?





--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Matt Martz

unread,
Feb 9, 2014, 4:20:37 PM2/9/14
to ansible...@googlegroups.com, habeeb rahman
When creating a dynamic inventory plugin, if you don't intend on actually putting hosts directly in the group, you still need to include the 'hosts' key to the group with an empty list.

Such as:

    "us-east-1_app1": {
        "children": [
            "app1"
        ,]
        "hosts": []
    },

    "app1": {
        "hosts": [
            "app000ea1",
            "app002ea2"
        ]
    },

Not doing so, basically has the outcome that you describe.  Ansible assumes that you mean that 'us-east1_app1' is to be an ungrouped host.

-- 
Matt Martz
ma...@sivel.net

Mihai Cristian Satmarean

unread,
Mar 8, 2017, 11:06:47 AM3/8/17
to Ansible Project, pk....@gmail.com
Hi, Can you share the script in a way, we are looking for ways to do the same.
Thanks!
Reply all
Reply to author
Forward
0 new messages