Skip to content

Instantly share code, notes, and snippets.

@KIVagant
Last active January 21, 2016 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KIVagant/bf33525ffea1def0186d to your computer and use it in GitHub Desktop.
Save KIVagant/bf33525ffea1def0186d to your computer and use it in GitHub Desktop.
Ansible 1.9 bug explanation (fixed in >2.0)
localhost ansible_connection=local
ansible-playbook -i localhost.ini test.yml --extra-vars="AAA=BBB"
```
TASK: [debug msg="{{hostvars[inventory_hostname][item]}}"] ********************
ok: [localhost] => (item=AAA) => {
"item": "AAA",
"msg": "CCC"
}
```
---
- name: Test playbook
hosts: all
vars:
AAA: AAA
tasks:
# How to get here variable value from --extra-vars?
- debug: msg="{{hostvars[inventory_hostname][item]}}"
with_items: var_list
when: hostvars[inventory_hostname][item] is defined
# group_vars/all/test.yml
AAA: CCC
var_list:
- AAA
@KIVagant
Copy link
Author

The problem fixed in Ansible 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment