Thank you @Stefan, 

That solves the issue !!

On Friday, March 6, 2020 at 2:32:07 PM UTC+5:30, Stefan Hornburg (Racke) 
wrote:
>
> On 3/6/20 9:04 AM, Shifa Shaikh wrote: 
> > I have a variable files like below: 
> > 
> > | 
> >   layers: 
> >     -name:APP 
> >       things: 
> >         -cactus 
> >         -lotus 
> >         -jasmine 
> >         -rose 
> >       bgcolor: 
> >         -sky blue 
> > 
> > 
> >     -name:WAS 
> >       things: 
> >         -mango 
> >         -apple 
> >       bgcolor: 
> >         -yellow 
> > | 
> > 
> > 
> > Below is my jinja template file: 
> > | 
> > {%forlayer inlayers %} 
> > <table bgcolor="{{ layer.bgcolor | list}}"> 
> > <tr> 
> > <th></th> 
> > {% for item in layer.things %} 
> > <th align="center">{{ item }}</th> 
> > {%endfor %} 
> > </tr> 
> > </table> 
> > {%endfor %} 
> > | 
> > 
>
> Try the join filter {{ layer.bgcolor | join(' ') }}. It is fruitless to 
> apply the list 
> filter to a list :-). 
>
> Regards 
>         Racke 
>
> > I run this with the below playbook: 
> > 
> > | 
> > --- 
> >   -name:Demonstratingvariables inJinja2Loops 
> >     hosts:localhost 
> >     connection:local 
> >     vars_files: 
> >       -vars.yml 
> >     gather_facts:no 
> >     tasks: 
> >       -name:Createthe Jinja2based templateone 
> > 
> >         template:src=./varloop_new.j2 dest=./output.txt 
> > | 
> > 
> > 
> > 
> > The output recieved has a problem.  
> > 
> > Output.txt: 
> > 
> > | 
> > -bash-4.2$ cat output.txt 
> > <table bgcolor="[u'sky blue']"> 
> > <tr> 
> > <th></th> 
> > <th align="center">cactus</th> 
> > <th align="center">lotus</th> 
> > <th align="center">jasmine</th> 
> > <th align="center">rose</th> 
> > </tr> 
> > </table> 
> > <table bgcolor="[u'yellow']"> 
> > <tr> 
> > <th> </th> 
> > <th align="center">mango</th> 
> > <th align="center">apple</th> 
> > </tr> 
> > </table> 
> > | 
> > 
> > 
> > It displays bgcolor="[u'sky blue']" instead of bgcolor="sky blue" 
> > 
> > How can I convert the list to a string in the jinja template. 
> > 
> > -- 
> > 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 
> > [email protected] <javascript:> <mailto:
> [email protected] <javascript:>>. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/ansible-project/10765862-e99b-44bf-bdb8-0db36c1fc49b%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/10765862-e99b-44bf-bdb8-0db36c1fc49b%40googlegroups.com?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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/59bb4061-7544-4846-9855-fb291065a0e1%40googlegroups.com.

Reply via email to