# dynamic inventory tiered groups

**URL:** <https://forum.ansible.com/t/dynamic-inventory-tiered-groups/18306>\
**Category:** Ansible Project\
**Created:** [May 26, 2015, 10:46am UTC](https://forum.ansible.com/t/dynamic-inventory-tiered-groups/18306 "2015-05-26T10:46:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marc\_Pascual](https://avatars.discourse-cdn.com/v4/letter/m/7bcc69/32.png) [@Marc\_Pascual](https://forum.ansible.com/u/Marc_Pascual)\
**Post date:** [May 26, 2015, 10:46am UTC](https://forum.ansible.com/t/dynamic-inventory-tiered-groups/18306/1 "2015-05-26T10:46:01Z")

</div>

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
