# Why when\_boolean and not when\_true/when\_false?

**URL:** <https://forum.ansible.com/t/why-when-boolean-and-not-when-true-when-false/12367>\
**Category:** Ansible Project\
**Created:** [February 16, 2013, 1:25am UTC](https://forum.ansible.com/t/why-when-boolean-and-not-when-true-when-false/12367 "2013-02-16T01:25:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nolan\_Darilek](https://avatars.discourse-cdn.com/v4/letter/n/919ad9/32.png) [@Nolan\_Darilek](https://forum.ansible.com/u/Nolan_Darilek)\
**Post date:** [February 16, 2013, 1:25am UTC](https://forum.ansible.com/t/why-when-boolean-and-not-when-true-when-false/12367/1 "2013-02-16T01:25:36Z")

</div>

when\_true/when\_false makes a bit more sense to me than does when\_boolean. I might assume that when\_boolean applies to a boolean value, but when\_true/when\_false not only makes that explicit, it also:

a) allows you to check for both values rather than just one  
b) is explicit about which value wins. when\_boolean could mean that true wins, or it could mean that any boolean value does. \*I\* know which this is, but it's ambiguous.

Would it make sense to replace these with when\_true/false and to deprecate when\_boolean, or to provide them in addition to when\_boolean?

Until then, what is the syntax for checking for a false boolean value? I suppose I could just leave it unset, but I'd rather explicitly state that a value is true or false rather than assuming unset == false.

Thanks.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 16, 2013, 2:03am UTC](https://forum.ansible.com/t/why-when-boolean-and-not-when-true-when-false/12367/2 "2013-02-16T02:03:40Z")

</div>

Because it's more flexible.

when\_boolean does a cast of every token in there to a boolean, ex, you  
can technically do:

when\_boolean: $a != $b

when\_boolean: $a and ( $b or $c )
