# variable precedence

**URL:** <https://forum.ansible.com/t/variable-precedence/14497>\
**Category:** Ansible Developer\
**Created:** [February 5, 2014, 7:19pm UTC](https://forum.ansible.com/t/variable-precedence/14497 "2014-02-05T19:19:54Z")\
**Posts on this page:** 3\
**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:** [February 5, 2014, 7:19pm UTC](https://forum.ansible.com/t/variable-precedence/14497/1 "2014-02-05T19:19:54Z")

</div>

Variable precedence is causing me some pain right now and would love  
to fix for the way vars\_files currently works, all I want is for -e to  
always win which is not currently the case. Are we open to fixing  
this? The last github issue that brought it up was closed  
([https://github.com/ansible/ansible/issues/2713?source=cc](https://github.com/ansible/ansible/issues/2713?source=cc))

In ansible 1.3 and 1.4 variables set in the vars\_files: file list will  
take precedence over extra-vars.

Thanks -John

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [February 5, 2014, 7:32pm UTC](https://forum.ansible.com/t/variable-precedence/14497/2 "2014-02-05T19:32:53Z")

</div>

So that’s a really really old github ticket and it’s generally good idea to not pretend any old github ticket has any bearing on today, as fast as things are moving.

1.2 was a rather annoying time with lots of threads about people wanting precedence implemented 10 different ways, and also roles being worked on, and at that time, it was probably correct.

-e should always rule, per docs, but -e values must also be usable in vars\_files

However, I’m not open to another vars precedence “how do we want this to work”, only reinstating that.

If you believe this is important to you and you can’t fix this, please make sure there is a new github ticket filed.

---

<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:** [February 5, 2014, 7:39pm UTC](https://forum.ansible.com/t/variable-precedence/14497/3 "2014-02-05T19:39:02Z")

</div>

> 1.2 was a rather annoying time with lots of threads about people wanting precedence implemented 10 different ways, and also roles being worked on, and at that time, it was probably correct.

Yeah I realize that, there is also this message on the list for the  
1.3 release - [https://groups.google.com/forum/#!searchin/ansible-project/possible$20documentation$20bug/ansible-project/zZyEqBbnxLU/XMhiJ9ms7LAJ](https://groups.google.com/forum/#!searchin/ansible-project/possible$20documentation$20bug/ansible-project/zZyEqBbnxLU/XMhiJ9ms7LAJ)  
I guess I should have been more pro-active on this issue since I was  
aware of it then.

> -e should always rule, per docs, but -e values must also be usable in vars\_files

Right now in 1.4 if the same variable is defined both in vars\_files  
and on the command line using -e the value in vars\_files will win.  
If I make the change to make it so -e wins over vars\_files do we see  
any potential issues? That's what we want right?
