vars:
foo: True
bar: False
foobar: '{{ foo and bar }}'
tasks:
- debug: msg="If foo is True"
when: foo
- debug: msg="If bar is False"
when: not bar
- debug: msg="foobar is True"
when: foobar
- debug: msg="foobar is false"
when: not foobar
- debug: msg="foobar|bool is false"
when: not foobar|bool
- debug:
var=foobar
PLAY [localhost] **************************************************************
TASK: [debug msg="If foo is True"] ********************************************
ok: [localhost] => {
"msg": "If foo is True"
}
TASK: [debug msg="If bar is False"] *******************************************
ok: [localhost] => {
"msg": "If bar is False"
}
TASK: [debug msg="foobar is True"] ********************************************
skipping: [localhost]
TASK: [debug msg="foobar is false"] *******************************************
skipping: [localhost]
TASK: [debug msg="foobar|bool is false"] **************************************
ok: [localhost] => {
"msg": "foobar|bool is false"
}
TASK: [debug var=foobar] ******************************************************
ok: [localhost] => {
"var": {
"foobar": "False"
}
}
PLAY RECAP ********************************************************************
localhost : ok=5 changed=0 unreachable=0 failed=0