I have a host that is a member of 2 groups. Both groups set a variable 'my_var' in `group_vars/<group_name>/`. How do I predict which one wins? (Ansible-1.9.2)
With this playbook:
I have a host that is a member of 2 groups. Both groups set a variable 'my_var' in `group_vars/<group_name>/`. How do I predict which one wins? (Ansible-1.9.2)
With this playbook:
Did you ever find out how this works? I have a variable that’s set in both group_vars/aws/secrets.yml and group_vars/aws_dogfood/secrets.yml, and I can’t figure out why on some servers it uses the variable from “aws” and others use the variable from “aws_dogfood”.
-Bill
The short answer is 'no', sorry.
But you've brought this back to my mind and hopefully I'll have a chance to find out. If you do, I'd love to hear it.
I suspect the behaviour is actually 'undefined' because in python, dicts are not ordered, but I'm not sure. Perhaps we could convince Ansible that this matters and to replace the relevant dict with an collections.OrderedDict and insert key/value pairs in a specific (lexicographic?) order.
In Ansible 2.0+, it's probably somewhere in the VariableManager class (lib/ansible/vars/__init__.py)