# jinja2 warning

**URL:** <https://forum.ansible.com/t/jinja2-warning/35603>\
**Category:** Ansible Project\
**Tags:** azure\
**Created:** [August 9, 2021, 1:10pm UTC](https://forum.ansible.com/t/jinja2-warning/35603 "2021-08-09T13:10:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahesh\_Nalavade](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mahesh_nalavade/32/7935_2.png) [@Mahesh\_Nalavade](https://forum.ansible.com/u/Mahesh_Nalavade)\
**Post date:** [August 9, 2021, 1:10pm UTC](https://forum.ansible.com/t/jinja2-warning/35603/1 "2021-08-09T13:10:54Z")

</div>

Hi ,

While running the ansible task in azure pipeline we are getting the below warning message. Please let us know if we can ignore/suppress the warning.

[WARNING]: conditional statements should not include jinja2 templating  
delimiters such as {{ }} or {% %}. Found: {% for item in hostvars.values() %}{%  
if item.MyDoneVar|default(False) %}True{% endif %}{% endfor %}

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [August 9, 2021, 2:18pm UTC](https://forum.ansible.com/t/jinja2-warning/35603/2 "2021-08-09T14:18:33Z")

</div>

> Hi ,
> 
> While running the ansible task in azure pipeline we are getting the below warning message. Please let us know if we can ignore/suppress the warning.
> 
> [WARNING]: conditional statements should not include jinja2 templating  
> delimiters such as {{ }} or {% %}. Found: {% for item in hostvars.values() %}{%  
> if item.MyDoneVar|default(False) %}True{% endif %}{% endfor %}

The logic behind your condition eludes me, but the expression for conditions are always subject to templating. This means you can't use {{, {% if, {% for etc.

You can start to convert your logic to

&nbsp;&nbsp;&nbsp;hostvar.values | dict2items | ... | count

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Mahesh\_Nalavade](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mahesh_nalavade/32/7935_2.png) [@Mahesh\_Nalavade](https://forum.ansible.com/u/Mahesh_Nalavade)\
**Post date:** [August 10, 2021, 5:54am UTC](https://forum.ansible.com/t/jinja2-warning/35603/3 "2021-08-10T05:54:13Z")

</div>

Hi Racke,

Can you please help me to form the logic as you suggested above for below condition

when: “{% for item in hostvars.values() %}{% if item.MyDoneVar|default(False) %}True{% endif %}{% endfor %}”

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [August 10, 2021, 6:54am UTC](https://forum.ansible.com/t/jinja2-warning/35603/4 "2021-08-10T06:54:07Z")

</div>

Instead of reverse engineering/guessing, why not tell us what you  
actually had in mind when you added that condition?

---

<div class="post-metadata">

**Author:** ![Mahesh\_Nalavade](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mahesh_nalavade/32/7935_2.png) [@Mahesh\_Nalavade](https://forum.ansible.com/u/Mahesh_Nalavade)\
**Post date:** [August 10, 2021, 8:47am UTC](https://forum.ansible.com/t/jinja2-warning/35603/5 "2021-08-10T08:47:08Z")

</div>

Hi,

I have 3 host in my inventory group as below  
Inventory:-
