I ran into the stupidest problem. I cannot figure out how to test boolean in Ansible 2.2 task file.
In vars/main.yml , I have:
destroy: false
The textbook has:
roles: - {'role': 'vmdeploy','destroy': true}
In the task file, I have the following:
- include: "create.yml" when: "{{ destroy|bool }} == 'false'"
I tried various combinations below:
when: "{{ destroy|bool }} == false" when: "{{ destroy|bool }} == 'false'" when: "{{ destroy|bool == false}}" when: "{{ destroy == false}}" when: "{{ destroy == 'false'}}" when: destroy|bool == false when: destroy|bool == 'false' when: not destroy|bool
In all of the above cases, I still get:
statically included: .../vmdeploy/tasks/create.yml
Debug output:
- debug: msg: "{{ destroy }}" --- ok: [atlcicd009] => { "msg": true }
The desired result is that it skips include.
Simply Seth
source share