# Child groups in External Inventory

**URL:** <https://forum.ansible.com/t/child-groups-in-external-inventory/13644>\
**Category:** Ansible Project\
**Created:** [October 9, 2013, 2:15pm UTC](https://forum.ansible.com/t/child-groups-in-external-inventory/13644 "2013-10-09T14:15:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phillip\_Verheyden](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@Phillip\_Verheyden](https://forum.ansible.com/u/Phillip_Verheyden)\
**Post date:** [October 9, 2013, 2:15pm UTC](https://forum.ansible.com/t/child-groups-in-external-inventory/13644/1 "2013-10-09T14:15:29Z")

</div>

I have customized the Rackspace inventory a bit to provide a bit better grouping for my specific scenario. Basically, I have special naming conventions for my servers:

---

So if I need a production Tomcat and Apache servers for a client called “Foo”, then I would name that server:

foo-prod-tomcat-1 - 1.1.1.1  
foo-prod-tomcat-2 - 2.2.2.2  
foo-prod-apache-1 - 3.3.3.3  
foo-prod-apache-2 - 4.4.4.4  
etc…

What I’m doing is exploding the names on the dash, so I get basically 5 groups (the numerical group I could probably leave off) that look like this:

foo =\> [1.1.1.1, 2.2.2.2, 3.3.3.3, 4.4.4.4]  
prod =\> [1.1.1.1, 2.2.2.2, 3.3.3.3, 4.4.4.4]  
tomcat =\> [1.1.1.1, 2.2.2.2]  
apache =\> [3.3.3.3, 4.4.4.4]

What I want is to properly denote that ‘prod’ is a child of ‘foo’, and ‘tomcat’ and ‘apache’ are children of ‘prod’. I just don’t know the proper format to do that in for the _JSON-encoded external_ inventory. The examples in the docs are just for static inventory.

I’m also aware of the metadata that you can give to Rackspace servers via their API, but I still have the question of the proper JSON format for child groups.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [October 9, 2013, 2:17pm UTC](https://forum.ansible.com/t/child-groups-in-external-inventory/13644/2 "2013-10-09T14:17:52Z")

</div>

Take a look at [http://ansibleworks.com/docs/developing\_inventory.html#id2](http://ansibleworks.com/docs/developing_inventory.html#id2)

(note: that id2 will change soon, but the subhead is “Script Conventions”)

---

<div class="post-metadata">

**Author:** ![Phillip\_Verheyden](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@Phillip\_Verheyden](https://forum.ansible.com/u/Phillip_Verheyden)\
**Post date:** [October 9, 2013, 2:20pm UTC](https://forum.ansible.com/t/child-groups-in-external-inventory/13644/3 "2013-10-09T14:20:59Z")

</div>

Awesome, thanks for the link. That answers my question.

In summary, for each group that has children, include a ‘children’ attribute for that group which has a list of its children.

Thanks!
