Last active
January 21, 2016 10:37
-
-
Save KIVagant/bf33525ffea1def0186d to your computer and use it in GitHub Desktop.
Ansible 1.9 bug explanation (fixed in >2.0)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
localhost ansible_connection=local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
} | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# group_vars/all/test.yml | |
AAA: CCC | |
var_list: | |
- AAA |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The problem fixed in Ansible 2