Child groups in External Inventory

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.

Take a look at http://ansibleworks.com/docs/developing_inventory.html#id2

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

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!