Skip to content

Instantly share code, notes, and snippets.

@tgerla
Created August 19, 2015 13:42
Show Gist options
  • Save tgerla/efa5e1ff2c04088e22f0 to your computer and use it in GitHub Desktop.
Save tgerla/efa5e1ff2c04088e22f0 to your computer and use it in GitHub Desktop.
Output with --extra-vars "hosts=foo":
Timothys-MacBook-Pro:ansible-test tgerla$ ansible-playbook -i inventory2 test-nulty.py --extra-vars "hosts=foo" -c local
PLAY [foo] ********************************************************************
skipping: no hosts matched
PLAY RECAP ********************************************************************
Output with --extra-vars "hosts= foo":
Timothys-MacBook-Pro:ansible-test tgerla$ ansible-playbook -i inventory2 test-nulty.py --extra-vars "hosts= foo" -c local
PLAY [] ***********************************************************************
GATHERING FACTS ***************************************************************
ok: [two]
ok: [one]
TASK: [debug] *****************************************************************
ok: [one] => {
"var": {
"hosts": ""
}
}
ok: [two] => {
"var": {
"hosts": ""
}
}
PLAY RECAP ********************************************************************
one : ok=2 changed=0 unreachable=0 failed=0
two : ok=2 changed=0 unreachable=0 failed=0
I guess what's happening is that we're parsing the extra vars as:
hosts: <empty string>
foo: <empty string>
Instead of:
hosts: " foo"
---
- hosts: "{{ hosts }}"
tasks:
- name: debug
debug: var=hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment