# \[WARNING\]: when statements should not include jinja2 templating delimiters such as {{ }} or {% %}.

**URL:** <https://forum.ansible.com/t/warning-when-statements-should-not-include-jinja2-templating-delimiters-such-as-or/24856>\
**Category:** Ansible Project\
**Created:** [June 29, 2017, 9:34pm UTC](https://forum.ansible.com/t/warning-when-statements-should-not-include-jinja2-templating-delimiters-such-as-or/24856 "2017-06-29T21:34:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![trg.achilles](https://avatars.discourse-cdn.com/v4/letter/t/f4b2a3/32.png) [@trg.achilles](https://forum.ansible.com/u/trg.achilles)\
**Post date:** [June 29, 2017, 9:34pm UTC](https://forum.ansible.com/t/warning-when-statements-should-not-include-jinja2-templating-delimiters-such-as-or/24856/1 "2017-06-29T21:34:04Z")

</div>

Hello,

I’m trying to remove jinja delimiter used in when condition.  
My condition tests whether partition exists on disk drive. I use variable to assign which drive to test  
vars:  
raw\_disk: ‘sdb’

task:

- include: lvm.yml  
when: ansible\_devices.{{ raw\_disk }}.partitions|length == 0

with {{ raw\_disk }} I receive [WARNING]: when statements should not include jinja2 templating delimiters such as {{ }} or {% %}.

What should be the correct condition so the variable can be included ansible facts

---

<div class="post-metadata">

**Author:** ![Josh\_Smift1](https://avatars.discourse-cdn.com/v4/letter/j/bcef8e/32.png) [@Josh\_Smift1](https://forum.ansible.com/u/Josh_Smift1)\
**Post date:** [June 29, 2017, 10:50pm UTC](https://forum.ansible.com/t/warning-when-statements-should-not-include-jinja2-templating-delimiters-such-as-or/24856/2 "2017-06-29T22:50:12Z")

</div>

> task:  
> &nbsp;&nbsp;- include: lvm.yml  
> &nbsp;&nbsp;&nbsp;&nbsp;when: ansible\_devices.{{ raw\_disk }}.partitions|length == 0

The shortcut a.b.c.d notation doesn't let you distinguish between literals  
and variables. Try the more Pythonic

&nbsp;&nbsp;when: ansible\_devices[raw\_disk]['partitions']|length == 0

and see if that does the trick.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-Josh (jbs@care.com)

(apologies for the automatic corporate disclaimer that follows)

This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.

---

<div class="post-metadata">

**Author:** ![trg.achilles](https://avatars.discourse-cdn.com/v4/letter/t/f4b2a3/32.png) [@trg.achilles](https://forum.ansible.com/u/trg.achilles)\
**Post date:** [June 30, 2017, 8:17am UTC](https://forum.ansible.com/t/warning-when-statements-should-not-include-jinja2-templating-delimiters-such-as-or/24856/3 "2017-06-30T08:17:22Z")

</div>

Josh, thank you for the hint. Work as expected.
