Unifying inventory file format

Hello,

Everything in ansible is yaml, except inventory file which is INI, and inventory scripts which output JSON.

Wouldn’t it be nice and more consistent to have inventory files in yaml, and inventory scripts outputing yaml ?

It would make it possible, for instance, to redirect the output of an inventory script to a file to have a snapshot inventory file, or to make it easy to create inventory scripts mixing static inventory files and dynamic content.

You’re sending a lot of emails today :slight_smile:

Nope, YAML doesn’t lend itself well to inventory.

YAML naturally defines a treeish structure, and groups are actually not a tree.

However if you want to, you could use an external inventory script and keep it in whatever format you like.

We used to have YAML inventory as an option in the early days but it was quite a mess, and included it as an inventory script for a while. It was removed because it didn’t keep parity with the rest of the
main code.

Ultimately I think keeping everything in the same format is a mistake – it’s better to keep everything in the best format.

Inventory scripts actually output JSON, because it’s more efficient – so the snapshot argument doesn’t quite hold anyway.