# Variable precedence not working as documented \[Ansible 1.5\]

**URL:** <https://forum.ansible.com/t/variable-precedence-not-working-as-documented-ansible-1-5/14858>\
**Category:** Ansible Project\
**Created:** [March 25, 2014, 10:41pm UTC](https://forum.ansible.com/t/variable-precedence-not-working-as-documented-ansible-1-5/14858 "2014-03-25T22:41:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Garrett\_Plasky](https://avatars.discourse-cdn.com/v4/letter/g/5f9b8f/32.png) [@Garrett\_Plasky](https://forum.ansible.com/u/Garrett_Plasky)\
**Post date:** [March 25, 2014, 10:41pm UTC](https://forum.ansible.com/t/variable-precedence-not-working-as-documented-ansible-1-5/14858/1 "2014-03-25T22:41:14Z")

</div>

I am referring to the documentation here: [http://docs.ansible.com/playbooks\_variables.html#variable-precedence-where-should-i-put-a-variable](http://docs.ansible.com/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable)

When I use vars\_files and “-e” (command line) variables together, I get results that appear to fly in the face of the aforementioned documentation. Exhibit A:

`

```auto
$ ansible --version
ansible 1.5.3
$ cat test_vars.yml
---
test_var: "from vars_files"
$ cat test.yml
---
- hosts: 127.0.0.1
  connection: local
  vars_files:
    - test_vars.yml
  tasks:
    - name: Testing variables
      debug: msg="{{ test_var }}"
$ ansible-playbook -i test test.yml -e "test_var='from command line'"

PLAY [127.0.0.1] **************************************************************

GATHERING FACTS ***************************************************************
ok: [127.0.0.1]

TASK: [Testing variables] *****************************************************
ok: [127.0.0.1] => {
    "msg": "from vars_files"
}

PLAY RECAP ********************************************************************
127.0.0.1 : ok=2 changed=0 unreachable=0 failed=0

```

`

Note that according to the docs, -e variables should “always win” but in this case, they clearly do not. What is the correct precedence as of Ansible 1.5?

---

<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:** [March 26, 2014, 11:44pm UTC](https://forum.ansible.com/t/variable-precedence-not-working-as-documented-ansible-1-5/14858/2 "2014-03-26T23:44:46Z")

</div>

The correct precedence is that “-e” should win.

So please file a github ticket on [github.com/ansible/ansible](http://github.com/ansible/ansible) so we can see about fixing it.

Thanks!

---

<div class="post-metadata">

**Author:** ![Garrett\_Plasky](https://avatars.discourse-cdn.com/v4/letter/g/5f9b8f/32.png) [@Garrett\_Plasky](https://forum.ansible.com/u/Garrett_Plasky)\
**Post date:** [March 27, 2014, 5:15pm UTC](https://forum.ansible.com/t/variable-precedence-not-working-as-documented-ansible-1-5/14858/3 "2014-03-27T17:15:15Z")

</div>

Sounds good, opened [https://github.com/ansible/ansible/issues/6724](https://github.com/ansible/ansible/issues/6724)
