How does one enforces that a "yes" or "no" answer will be converted into a boolean value when defining a vars_promp
?
For instance. With this playbook:
---
- name: variable tests
hosts: local
gather_facts: false
vars:
answer1: yes
vars_prompt:
- name: "answer2"
prompt: "Reply true"
private: no
- name: "answer3"
prompt: "Reply yes"
private: no
tasks:
- debug: msg="answer1 is true"
when: answer1
- debug: msg="answer2 is true"
when: answer2
- debug: msg="answer3 is true"
when: answer3
The last task will fail since answer3
is a string with value "yes". It isn't converted into a boolean value as when specifying "true" (answer2).
Converting to a true or false boolean is already the behaviour when using vars
(as in answer1).