Skip to content

Instantly share code, notes, and snippets.

@caylorme
Last active September 10, 2015 01:15
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 caylorme/02faff5c65f9e2058e02 to your computer and use it in GitHub Desktop.
Save caylorme/02faff5c65f9e2058e02 to your computer and use it in GitHub Desktop.
A bug in ansible?
localhost inventory_variable=true ansible_connection=local
---
- name: Testing Issue
hosts: all
pre_tasks:
- debug: var={{ item }}
with_items:
- inventory_variable
- playbook_variable
roles:
- role: role1
playbook_variable: "{{ inventory_variable | default(false) }}"
---
- name: Test Playbook Variable
debug: var=playbook_variable
@caylorme
Copy link
Author

ansible-playbook -i my_inventory playbook.yml

PLAY [Testing Issue] **********************************************************

GATHERING FACTS ***************************************************************
ok: [localhost]

TASK: [debug var={{ item }}] **************************************************
ok: [localhost] => (item=inventory_variable) => {
"item": "inventory_variable",
"var": {
"inventory_variable": "true"
}
}
ok: [localhost] => (item=playbook_variable) => {
"item": "playbook_variable",
"var": {
"playbook_variable": "playbook_variable"
}
}

TASK: [role1 | Test Playbook Variable] ****************************************
ok: [localhost] => {
"var": {
"playbook_variable": "False"
}
}

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

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