Nice. I love how Ansible is like a box of chocolates.
I missed that addition to 0.5 – breezed right over it and didn’t notice it. sigh.
As an aside, Is the INI format the general preference for inventory files given how YAML seems to trail it in terms of support?
Warning: complicated answer. I want to discuss the present as well as the future.
I strongly prefer the INI format, except that the YAML format has a way to represent lists and hash data, for that need them in a host or group specific way. I think this is a small minority of users, but a vocal minority who does in fact really need them. It is definitely a mess how they don’t have the same capabilities.
I have been thinking about how to eliminate YAML, and one way to do it might be for ansible to try to auto load certain files per group name and host name automatically, and let THESE files be YAML.
For instance, what if ansible ALWAYS tried to load variables in:
/etc/ansible/vars/$inventory_hostname.yml (the paths not actually just being /etc, but relative to the inventory file)
And also:
/etc/ansible/vars/$group.yml (for all possible group names)
If these files were not there, it would not load them, and it would be fine.
Another option might be to just tell people HOW to do this as a pattern, but then you’d have to include that boilerplate in every play, which I don’t like.
In this situation, we would no longer need to be able to store nested lists and hashes in the YAML inventory file, because of these implicit loads, you could easily move things to other files, and it would work basically like a vars_files line you’d never have to write yourself.
As a result, we could standardize on the INI format, and hopefully write a script to help people migrate.
I really want one format – maintaining two parsers does not make sense with the goals of this project, and kinda runs counter to project goals of being minimal. YAML was done as a great way to be able to represent structured data, but the fact that the groups are not strictly hierarchal, but YAML makes you build a tree (with relatively high levels of indentation) makes it a mess as a way of describing inventory.
This would have to be a two stage thing, we’d have to add this auto-load capability first, and ship that, and then write a conversion tool and deprecate YAML in a future release.
I don’t want to leave anyone out in the cold though, and would refuse to do this without a migration tool. However, since that tool could use the existing ansible API, it wouldn’t be rocket science.
Thoughts?