Skip to content

Instantly share code, notes, and snippets.

@berlic
Created July 12, 2017 12:29
Show Gist options
  • Save berlic/2fd91e9925c66419d5d27b3a5111cbde to your computer and use it in GitHub Desktop.
Save berlic/2fd91e9925c66419d5d27b3a5111cbde to your computer and use it in GitHub Desktop.
bool conversion demo
---
- hosts: localhost
gather_facts: no
tasks:
- debug: msg=var1
when: var1
- debug: msg=var2
when: var2
- debug: msg=both
when: var1 or var2
- debug: msg=both2
when: var1 | bool or var2 | bool
@berlic
Copy link
Author

berlic commented Jul 12, 2017

execute with ansible-playbook -vv -e var1=false -e var2=false playbook.yml

@berlic
Copy link
Author

berlic commented Jul 12, 2017

msg=both will fire in spite of having both vars set to "false"

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