Using Ansible 1.3.4
According to the docs, this is the precedence:
* -e variables always win
* then comes "most everything else"
* then comes variables defined in inventory
* then "role defaults", which are the most "defaulty" and lose in priority to everything.
I am finding this is true except in the case of of variables imported via vars_files. So given the following play in a playbook someplay.yml:
---
- hosts: all
remote_user: root
vars:
favcolor: blue
vars_files:
- /vars/external_vars.yml
tasks:
- name: this is just a placeholder
command: /bin/echo foo
And the following in /vars/external_vars.yml:
---
favfood: pizza
And I invoke the playbook with:
ansible-playbook someplay.yml -e '{"favfood":"bacon","favcolor":"bacon"}'
I end up with favfood=pizza, favcolor=bacon. The actual order is:
- variables in external files that are referenced with vars_files
- -e
- everything else (playbook vars, roles/vars, inventory vars, roles/defaults, etc…)
There is a closed issue here that seems to indicate that this behavior is correct and that the documentation is wrong. However the issue is from some time ago - so which is it now?