jinja2 warning

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 %}

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

   hostvar.values | dict2items | ... | count

Regards
           Racke

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 %}”

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

Hi,

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