Hello ansiblers
When using an inventory file I can define vars in group_vars/{groupname,hostname} and they are loaded automatically but when using an inventory script this doesn't work. Some question:
- Is this intended behaviour?
- If so, any hint to get an equivalent of inventory_script+group_vars behaviour?
I could hack the inventory script to load things from group_vars/* but the groups a host belongs to are not available when the inventory is called for '--host foo' so I could load any group_vars/$hostname but not a group_vars/$groupname (at least the inventory is reparsed at '--host' time to find outs current groups for given host).
Is this inventory_script + static groups_vars nonsense/crazy?
The behaviour I'm trying to get from Ansible is:
- look if a var is defined for a host
- if not, look if defined for a group
- if not, look if defined in defaults
- if not, no such var
vars_file: [ $group.yml, default.yml ] would work but then host vars from inventory script will be ignored because of precedence rules.
groups_vars/groupname would work but group_vars are ignored when using an inventory_script.
having both default_<varname> and <varname> and filling templates with {% if defined <varname> %} something with <varname> {% else %} something with default_<varname> {% endif %} would work but this is ugly as hell.
So... thanks for your help/recommendations/criticisms.
Regards,
maykel