# precedence bug or is this by design?

**URL:** <https://forum.ansible.com/t/precedence-bug-or-is-this-by-design/13377>\
**Category:** Ansible Project\
**Created:** [August 28, 2013, 4:53pm UTC](https://forum.ansible.com/t/precedence-bug-or-is-this-by-design/13377 "2013-08-28T16:53:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Jarvis](https://avatars.discourse-cdn.com/v4/letter/j/e47774/32.png) [@John\_Jarvis](https://forum.ansible.com/u/John_Jarvis)\
**Post date:** [August 28, 2013, 4:53pm UTC](https://forum.ansible.com/t/precedence-bug-or-is-this-by-design/13377/1 "2013-08-28T16:53:50Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 28, 2013, 8:40pm UTC](https://forum.ansible.com/t/precedence-bug-or-is-this-by-design/13377/2 "2013-08-28T20:40:14Z")

</div>

-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.

---

<div class="post-metadata">

**Author:** ![John\_Jarvis](https://avatars.discourse-cdn.com/v4/letter/j/e47774/32.png) [@John\_Jarvis](https://forum.ansible.com/u/John_Jarvis)\
**Post date:** [August 30, 2013, 2:15pm UTC](https://forum.ansible.com/t/precedence-bug-or-is-this-by-design/13377/3 "2013-08-30T14:15:31Z")

</div>

Thanks, opened [https://github.com/ansible/ansible/issues/3974](https://github.com/ansible/ansible/issues/3974)

---

<div class="post-metadata">

**Author:** ![John\_Jarvis](https://avatars.discourse-cdn.com/v4/letter/j/e47774/32.png) [@John\_Jarvis](https://forum.ansible.com/u/John_Jarvis)\
**Post date:** [August 30, 2013, 2:16pm UTC](https://forum.ansible.com/t/precedence-bug-or-is-this-by-design/13377/4 "2013-08-30T14:16:27Z")

</div>

Also - (I added it to the bug report) this behavior is observed in both 1.2 and 1.3.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [August 30, 2013, 2:26pm UTC](https://forum.ansible.com/t/precedence-bug-or-is-this-by-design/13377/5 "2013-08-30T14:26:57Z")

</div>

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.
