It's weird. If anything, I'd be in favor of getting rid of the old
ad-hoc format. To use ansible for more than a one-off job, you need to
learn YAML anyway. I wrote the inventory for two reasons: to use per
host defined vars in a straightforward way and because of the
uniformity with the rest of ansible. Plus it's pretty syntax
highlighted. The simplest form is also simple:
While the simplest form of the YAML format is simple. I think the way of representing group and host vars doesn't quite work with my brain. Long ago I swore I wasn't going to force YAML configuration files on people again, and I'm kind of doing it. I strongly dislike that, presently, the YAML mode is the only way to do complex things with the configuration, and we're on the edge of adding more to it. YAML is a format where it is easy to make errors which render your configuration not working. I am accepting of that when doing playbooks, because there is a minor level of nesting, but this nesting should not be necessary to express inventory.
Either way, changing topics, making changes in the inventory code is becoming difficult, so I'm going to be working on another rev of the inventory code to make it a bit more OO, while still keeping the interface that is exposed to ansible and ansible-playbooks compatible.
We need a Inventory() class that just represents Inventory, in terms of Group objects and Host objects. These need
methods on each class, with variables on each host, and variables on each group.
You should be able to call a method on each host and get variables, etc. It shouldn't be using low level data structures.
Then we have another file that contains the parser, and produces an Inventory object that can be asked Host and Group questions.
The Inventory object should support a serialize method that dumps the configuration back out too -- so if I wanted to shoot other code in the head, and make it possible to implement cobbler integration in terms of a cron tab on a cobbler trigger, we could do that. The result is a vast simplification of having 3 ways to do something into one, and not requiring people to suffer learning two different YAML dialects.
---
- myhost1
- myhost2
No potential user will be scared of that, especially when you play the
reuse card while explaining it.
That's a straw-man though compared to the fully fleshed out version. To be fair, it offers a ton of great capabilities, and that was a very impressive feature… that being said, about half the folks out find it a bit confusing, and I don't want to keep adding to it.
We already have a 'custom language' in playbooks. Do we want a
completely different second one?
Essentially that's what the YAML playbook format actually is -- a second language, complete with indentation rules.
However, INI files (we may have to iterate on the syntax some) are pretty basic. And this is forward compatible with what we have now, since the sections are arbitrary.
Since the type of the YAML inventory file is presently a list, it is difficult to do things like top level variables, or express global settings.
Essentially the inventory file is more or less becoming settings, and … yeah … I have to go with my gut feel here that YAML as a configuration file is a source of problems. Especially when converting from simple hosts to groups of hosts, with group vars and host vars is non-intuitive.