Enter code here...
When I pass a variable to include: statement, using value from extra vars, 
the value inside the included task file is still the value from host_vars, 
not extra vars (while extra vars are considered as highest precedence)

Here'e an example

*main.yml*


- name: test extra var
  hosts: localhost
    connection: local
  gather_facts: no

  tasks:
    - include: task.yml internal_var={{my_var}}



*task.yml*

- name: print internal_var

  debug: msg="hello, {{internal_var}}"


*inventory*
[local]

localhost ansible_connection=local


*host_vars/localhost*
my_var: I am from host_vars

then test



LAZ-VN-L-M-1034:test user$ ansible-playbook -i inventory main.yml -e 
'my_var=testtest'

PLAY [pulling Avanan Registration Management UI from git remote repository] 
*** 

TASK: [print internal_var] 
**************************************************** 
ok: [localhost] => {
    "msg": "hello, I am from host_vars"
}

PLAY RECAP 
******************************************************************** 
localhost                  : ok=1    changed=0    unreachable=0    failed=0 
  

 


It still takes value from host_vars/localhost even though extra var is 
passed.


Is it an error? Ansible version is  1.9.4


-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6670789a-e4b2-4fe0-a662-a3d4f96ac3c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to