I was waiting for this question 🙂
For me, host variables like you mentioned have better use in simpler scenarios. Most of the configuration files have a lot of data, so keeping all the parameters in a separated JSON file would be a best practice. Instead of mixing them with inventory data, the design principle was applied.
In addition, this approach gives flexibility. The JSON file can grow and the inventory will be the same. JSON nodes can be simply added, removed or changed, as needed.
Last but not least, you must know the host variables placed in the inventory file, in order to use them in the playbook. Differently, the solution allows adding parameters to a configuration file with no need of knowing them upfront. The items node has all the key/value pairs the configuration file requires.
Regards,
Gustavo.
]]>What’s the difference with host vars ?
]]>