Hi All,
Found something strange (possible bug?) in evaluating True/False inside vars.
Only in one particular case - if variable is evaluated as “False” - its not converted to “True” with “not”
In my example false_eval is evaluated to “False” inside debug module but “not false_eval” is still “False”. Any reason for that?
- debug: var=false_eval
TASK: [debug var=false_eval] **************************************************
ok: [localhost] => {
“false_eval”: “False”
}
- debug: var={{not false_eval}}
TASK: [debug var=False] *******************************************************
ok: [localhost] => {
“False”: “False”
}
playbook.yml
- hosts: localhost
gather_facts: no
vars:
foo: bar
true_eval: ‘{{ foo == “bar” }}’
false_eval: ‘{{ foo != “bar” }}’
tasks:
- debug: var=true_eval
- debug: var={{ not true_eval }}
- debug: var=false_eval
- debug: var={{not false_eval}}
Output:
PLAY [localhost] **************************************************************
TASK: [debug var=true_eval] ***************************************************
ok: [localhost] => {
“true_eval”: “True”
}
TASK: [debug var=False] *******************************************************
ok: [localhost] => {
“False”: “False”
}
TASK: [debug var=false_eval] **************************************************
ok: [localhost] => {
“false_eval”: “False”
}
TASK: [debug var=False] *******************************************************
ok: [localhost] => {
“False”: “False”
}
PLAY RECAP ********************************************************************
localhost : ok=4 changed=0 unreachable=0 failed=0
Ansible 1.4.4
Thanks