evaluating a variable value as boolean

29 views
Skip to first unread message

Shashank Dutt Jha

unread,
Jul 11, 2019, 8:34:32 AM7/11/19
to Ansible Project
I have defined variable 
happened: true 

When am trying to use this variable in task in conditional when clause it failed
when: {{happened}} | bool == true it gives error.

what is the correct syntax to use it?

Soniya panwar

unread,
Jul 12, 2019, 2:53:15 AM7/12/19
to Ansible Project
Hello Shashank,

This statement is getting failed because you didn't use double quotes (" ") in your command. 
The correct syntax to use this statement is:

when: "{{happened}} | bool == true"



Thanks 
Soniya

Brian Coca

unread,
Jul 15, 2019, 11:17:25 AM7/15/19
to Ansible Project
conditionals already assume {{ }} context, so unless you are
specifically aiming at double interpolation `when: happened|bool` is
all you need


--
----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages