Hi all, just wanted to write about a fix/change I'll be merging into the
devel branch soon (ie. as soon as the AWS outage quits impacting our
testing infrastructure), which means it will be included in the 2.3.0
release.

Per our variable precedence docs (
http://docs.ansible.com/ansible/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable),
the variables provided by the inventory script or INI file are supposed to
be lower priority than those found in group_vars and host_vars files,
however this has not been the case in 2.0 and it has gone unnoticed thus
far.

While fixing this to match our documentation however, we realized that the
precedence docs had a problem - variables defined on the host in the
script/INI file would in fact have lower precedence than those in
group_vars/all (or any group_vars files). We've decided to fix this based
on the following rules for inventory:

1) Host Vars > Group Vars
2) Things relative to the playbook > Things relative to the inventory >
Things defined in inventory

For those who are unfamiliar with the second point above, it is possible to
have host/group vars files defined relative to both the playbook and to the
inventory. For example, if you have:

playbook/site.yml
playbook/group_vars/all
inventory/hosts
inventory/group_vars/all

And you run:

$ ansible-playbook -i inventory/hosts playbook/site.yml

the variables in playbook/group_vars/all will "win" over those in
inventory/group_vars/all.

Prior to this change, if you had something like:

ansible_connection: local

In any group_vars/all file, it would have "won" over anything defined in
the inventory script, even if you did something like:

myhost ansible_connection=paramiko

the value in the group_vars would have been the value used, which is
counter-intuitive.

If anyone has any questions regarding this change, please let us know.

Thanks!

James Cammarata

Ansible Lead/Sr. Principal Software Engineer
Ansible by Red Hat
twitter: @thejimic, github: jimi-c

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAMFyvFgMtr%2B4dYEpZ%2BqCjPXfRf%3DEDdK%3DN3L1RubgRZORJfTbvQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to