is nested yaml inventory file for ansible supported?

Hi Guys,

I’m trying to use a yaml file as inventory file which looks like below:

It doesn’t seem to work, and I couldn’t find much info on ansible docs around yaml inventory file.
Please let me if above yaml works as inventory file in any ansible version ?.. thanks in advance!

There is an example yaml inventory on github explaining the structure. You can find it at:

https://github.com/ansible/ansible/blob/devel/examples/hosts.yaml

Specifically, note from the example Matt provided that all values in the YAML inventory file are map values, never lists. So the - (dash) preceding your “prod” and “stag” groups should be removed. Also note that all hosts listed under a “host:” mapping are also mapping values, so must end with a colon. Finally, groups which are children of other groups should be listed under the “children:” mapping under the parent group. So your example should look like:

`

Thanks Matt and Milo, we have tried Milo way of inventory file, it works…everything is key now!

Hi Milo,

It does work in SLES system but doesn’t work in Ubuntu system.
In ubuntu, it lists every key in yaml file

Below are the sample example for the same:

vi inv

This does not look like a platform problem, probably due to using a different configuration.

The ubuntu machine is parsing the file using the ‘ini’ format, the suse is using the yaml format.

Use -vvv to get more info on why that is happening, you are probably getting errors or warnings or have the systems with non default configurations.