group_vars/* and inventory script (and vars vars vars)

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

ansible --version?

ansible-playbook 1.1 (devel 0c80c76833) last updated 2013/03/13 12:23:21 (GMT +200)

Thanks,
maykel

[self-response thanks to dhozac]

I missed the 'relative to the inventory file' part in [1] and had the group_vars/ dir relative to the playbook instead of the inventory script.

It's working now as expected with:
- inventory_script
- groups_var/<groupname>
- groups_var/all

Sorry for the noise.

Regards,
maykel

[1] http://ansible.cc/docs/patterns.html#splitting-out-host-and-group-specific-data