Last active
March 6, 2018 09:02
-
-
Save evgeni/2fbbf0c934d1e78679fb90237f01b7c4 to your computer and use it in GitHub Desktop.
to bool or not to bool
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 to_bool_or_not_to_bool.yml -e false_lower=false -e false_upper=False -e true_lower=true -e true_upper=True | |
PLAY [localhost] ****************************************************************************************** | |
TASK [debug] ********************************************************************************************** | |
ok: [localhost] => (item=false_lower) => { | |
"changed": false, | |
"false_lower": "false", | |
"item": "false_lower" | |
} | |
ok: [localhost] => (item=false_upper) => { | |
"changed": false, | |
"false_upper": false, | |
"item": "false_upper" | |
} | |
ok: [localhost] => (item=true_lower) => { | |
"changed": false, | |
"item": "true_lower", | |
"true_lower": "true" | |
} | |
ok: [localhost] => (item=true_upper) => { | |
"changed": false, | |
"item": "true_upper", | |
"true_upper": true | |
} | |
TASK [debug] TASK [debug] ********************************************************************************************** | |
skipping: [localhost] => (item=false) | |
skipping: [localhost] => (item=False) | |
ok: [localhost] => (item=true) => { | |
"changed": false, | |
"item": "true", | |
"msg": "true is True" | |
} | |
ok: [localhost] => (item=True) => { | |
"changed": false, | |
"item": true, | |
"msg": "True is True" | |
} | |
TASK [debug] TASK [debug] ********************************************************************************************** | |
skipping: [localhost] => (item=false) | |
ok: [localhost] => (item=False) => { | |
"changed": false, | |
"item": false, | |
"msg": "False is False" | |
} | |
skipping: [localhost] => (item=true) | |
skipping: [localhost] => (item=True) | |
TASK [debug] TASK [debug] ********************************************************************************************** | |
ok: [localhost] => (item=false) => { | |
"changed": false, | |
"item": "false", | |
"msg": "jinja says false is True" | |
} | |
ok: [localhost] => (item=False) => { | |
"changed": false, | |
"item": false, | |
"msg": "jinja says False is False" | |
} | |
ok: [localhost] => (item=true) => { | |
"changed": false, | |
"item": "true", | |
"msg": "jinja says true is True" | |
} | |
ok: [localhost] => (item=True) => { | |
"changed": false, | |
"item": true, | |
"msg": "jinja says True is True" | |
} | |
PLAY RECAP ************************************************************************************************ | |
localhost : ok=4 changed=0 unreachable=0 failed=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
- hosts: localhost | |
gather_facts: no | |
tasks: | |
- debug: | |
var: "{{ item }}" | |
with_items: | |
- false_lower | |
- false_upper | |
- true_lower | |
- true_upper | |
- debug: | |
msg: "{{ item }} is True" | |
when: item | |
with_items: | |
- "{{ false_lower }}" | |
- "{{ false_upper }}" | |
- "{{ true_lower }}" | |
- "{{ true_upper }}" | |
- debug: | |
msg: "{{ item }} is False" | |
when: not item | |
with_items: | |
- "{{ false_lower }}" | |
- "{{ false_upper }}" | |
- "{{ true_lower }}" | |
- "{{ true_upper }}" | |
- debug: | |
msg: "jinja says {{ item }} is {% if item %}True{% endif %}{% if not item %}False{% endif %}" | |
with_items: | |
- "{{ false_lower }}" | |
- "{{ false_upper }}" | |
- "{{ true_lower }}" | |
- "{{ true_upper }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment