Variables defined in /vars/main.yml seem to take precedence over variables passed into -e except when they are used in jinja templates. Here is a very simple example:
playbook:—
- hosts: localhost
roles: - test
roles/test/vars/main.yml:
Variables defined in /vars/main.yml seem to take precedence over variables passed into -e except when they are used in jinja templates. Here is a very simple example:
playbook:—
roles/test/vars/main.yml:
-e variables are supposed to always consistently win, so I would consider this a bug.
Please make sure one is filed in github.
The Ansible way kind of says it’s always best to not overcomplicate things by not defining variables in 7 different places, but it’s important that we are consistent. I’m sure this is a minor side effect of role scope improvements – which are otherwise a strong net win, so it’s a minor glitch to polish out.
Thanks, opened https://github.com/ansible/ansible/issues/3974
Also - (I added it to the bug report) this behavior is observed in both 1.2 and 1.3.
Responded on github, but will here as well for the benefit of the list. The patches I merged in for the role default work this morning included a fix for this.