Variable precedence not working as documented [Ansible 1.5]

48 views
Skip to first unread message

Garrett Plasky

unread,
Mar 25, 2014, 6:41:14 PM3/25/14
to ansible...@googlegroups.com
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?

Michael DeHaan

unread,
Mar 26, 2014, 7:44:46 PM3/26/14
to ansible...@googlegroups.com
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!


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7c7d786f-6ae5-48f9-907e-1d66df8fcfb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Garrett Plasky

unread,
Mar 27, 2014, 1:15:15 PM3/27/14
to ansible...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages