@Stefan sorry but I could not understand your statement. 

Are you asking me to move the if statement out of the jinja template ?

Below is the complete jinja template with the if statement that errors. I'm 
able to populate all the values correctly and the playbook works fine when 
the if statement is removed from the jinja template. 

{% for layer in layers %}
<table>
<tr>
<th> </th>
{% for item in layer.things %}

{% if {{ playbook_dir }}/{{ item }}/bad*.txt | exists %}
<th align="center">{{ item }}</th>

{% else %}
<th align="left">{{ item }}</th>

{% endif %}

{% endfor %}
</tr>
</table>
{% endfor %}

On Friday, March 6, 2020 at 5:08:37 PM UTC+5:30, Stefan Hornburg (Racke) 
wrote:
>
> On 3/6/20 12:02 PM, Jean-Yves LENHOF wrote: 
> > Hi, 
> > 
> > Your error is about a for loop, but your template included in your email 
> doesn't have this loop. 
>
> The loop could be applied to the task, in that case you can use {{ item }} 
> in the template on its own. 
>
> Regards 
>          Racke 
>
> > 
> > Looks like you didn't give us the good one 
> > 
> > Regards, 
> > 
> > JYL 
> > 
> > 
> > Le 06/03/2020 à 11:52, Shifa Shaikh a écrit : 
> >> Vladimir Hi,  
> >> 
> >> I tried  
> >> 
> >> | 
> >> {%if{{playbook_dir }}/{{item }}/bad*.txt |exists %} 
> >> 
> >> 
> >> <th align="center">{{item }}</th> 
> >> 
> >> 
> >> 
> >> {%else%} 
> >> 
> >> 
> >> <th align="left">{{item }}</th> 
> >> 
> >> 
> >> 
> >> {%endif %} 
> >> 
> >> | 
> >> 
> >> But I get this error: 
> >> 
> >> | 
> >> TASK [Createthe Jinja2based 
> >> 
> template]*********************************************************************************************************************
>  
>
> >> fatal:[localhost]:FAILED!=>{"changed":false,"msg":"AnsibleError: 
> template error while templating string: expected 
> >> token ':', got '}'. String: {% for layer in layers %}\n........ 
> >> | 
> >> 
> >> 
> >> 
> >> 
> >> On Friday, March 6, 2020 at 3:36:04 PM UTC+5:30, Vladimir Botka wrote: 
> >> 
> >>     On Fri, 6 Mar 2020 01:59:00 -0800 (PST) 
> >>     Shifa Shaikh <shif...@gmail.com <javascript:>> wrote: 
> >> 
> >>     > How do i  put the if /else condition in the jinja template ? 
> >> 
> >>     See "if" 
> >>     https://jinja.palletsprojects.com/en/2.11.x/templates/#if <
> https://jinja.palletsprojects.com/en/2.11.x/templates/#if> 
> >> 
> >> 
> >> -- 
> >> You received this message because you are subscribed to the Google 
> Groups "Ansible Project" group. 
> >> To unsubscribe from this group and stop receiving emails from it, send 
> an email to 
> >> ansible...@googlegroups.com <javascript:> <mailto:
> ansible-project+unsubscr...@googlegroups.com <javascript:>>. 
> >> To view this discussion on the web visit 
> >> 
> https://groups.google.com/d/msgid/ansible-project/e2c31593-0389-4c5d-9bbb-9f29e528a832%40googlegroups.com
>  
> >> <
> https://groups.google.com/d/msgid/ansible-project/e2c31593-0389-4c5d-9bbb-9f29e528a832%40googlegroups.com?utm_medium=email&utm_source=footer>.
>  
>
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "Ansible Project" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to 
> > ansible...@googlegroups.com <javascript:> <mailto:
> ansible-project+unsubscr...@googlegroups.com <javascript:>>. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/ansible-project/44bc6389-53a2-31d9-62a4-25897191e902%40lenhof.eu.org
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/44bc6389-53a2-31d9-62a4-25897191e902%40lenhof.eu.org?utm_medium=email&utm_source=footer>.
>  
>
>
>
> -- 
> Ecommerce and Linux consulting + Perl and web application programming. 
> Debian and Sympa administration. Provisioning with Ansible. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fc1f3a81-c882-4b57-9644-8341ac95500c%40googlegroups.com.

Reply via email to