# when conditionals syntax

**URL:** <https://forum.ansible.com/t/when-conditionals-syntax/26604>\
**Category:** Ansible Project\
**Created:** [January 30, 2018, 4:16pm UTC](https://forum.ansible.com/t/when-conditionals-syntax/26604 "2018-01-30T16:16:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Harmon](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@John\_Harmon](https://forum.ansible.com/u/John_Harmon)\
**Post date:** [January 30, 2018, 4:16pm UTC](https://forum.ansible.com/t/when-conditionals-syntax/26604/1 "2018-01-30T16:16:37Z")

</div>

Is something wrong with the following? It seems to get executed no matter what. In addition, where can I find more information about this syntax? Is this considered jinja2 syntax? or something else?

`

- include\_tasks: install.yml  
when: ( install|default(false)|lower = “true” | “yes” ) && nagios\_user|failed

`

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [January 30, 2018, 4:22pm UTC](https://forum.ansible.com/t/when-conditionals-syntax/26604/2 "2018-01-30T16:22:17Z")

</div>

Yes, you use of `| "yes"` is not proper jinja2.

`|` is used to “pipe” something into a filter function, and “yes” is not a filter function.

Are you trying to check if it also “yes”. Look to using the bool filter (also use `and` instead of `&&`):

```auto
when: install|default(false)|bool and nagios_user is failed

```

---

<div class="post-metadata">

**Author:** ![John\_Harmon](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@John\_Harmon](https://forum.ansible.com/u/John_Harmon)\
**Post date:** [January 30, 2018, 4:27pm UTC](https://forum.ansible.com/t/when-conditionals-syntax/26604/3 "2018-01-30T16:27:37Z")

</div>

Thanks Matt. Works perfectly. I will have to go and look up some jinja2 documentation. Thanks again!
