dynamic inventory tiered groups

41 views
Skip to first unread message

Marc Pascual

unread,
May 26, 2015, 9:35:54 AM5/26/15
to ansible...@googlegroups.com
Hello!

I'm new to ansible, and I am trying to figure out how the json output should look like if I have a flat-file inventory source like:

# application:environment=hostlist
heroes:marvel=thor hulk stark cap
heroes:dc=supe bats flash robin
colors:primary=red blue yellow
colors:secondary:green orange violet

lol:~/scripts/python bash-3.2$ ./inv.py --list
{
    "heroes": {
        "dc": [
            "supe",
            "bats",
            "flash",
            "robin"
        ],
        "marvel": [
            "thor",
            "hulk",
            "stark",
            "cap"
        ]
    },
    "colors": {
        "primary": [
            "red",
            "blue",
            "yellow"
        ],
        "secondary": [
            "green",
            "orange",
            "violet"
        ]
    }
}

I am looking to run one liners against groups and sub groups such as:
 
ansible -i ~/bin/inv.py colors -m 'uname -n'
(runs uname against red, blue, yellow, green, orange, violet)

ansible -i ~/bin/inv.py primary -m 'uname -n'
(runs uname against green, orange, violet)

Or, I could be going about this all wrong. Can anyone give me a hint? 

cheers,
Marc


Reply all
Reply to author
Forward
0 new messages