boolean - Using True False with Ansible When Clause -


i'm running silliest issue. cannot figure out how test boolean in ansible 2.2 task file.

in vars/main.yml, have:

destroy: false 

in playbook, have:

roles:    - {'role': 'vmdeploy','destroy': true} 

in task file, have following:

- include: "create.yml"   when: "{{ destroy|bool }} == 'false'" 

i've 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 above cases, still get:

statically included: .../vmdeploy/tasks/create.yml 

debug output:

- debug:     msg: "{{ destroy }}"  ---  ok: [atlcicd009] => { "msg": true } 

the desired result, skip include.

to run task when destroy true:

--- - hosts: localhost   connection: local   vars:     destroy: true   tasks:     - debug:       when: destroy 

and when destroy false:

--- - hosts: localhost   connection: local   vars:     destroy: false   tasks:     - debug:       when: not destroy 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -