Variable precedence not working as documented [Ansible 1.5]

I am referring to the documentation here: 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:

`

$ 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?

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

So please file a github ticket on github.com/ansible/ansible so we can see about fixing it.

Thanks!

Sounds good, opened https://github.com/ansible/ansible/issues/6724