@Stefan i tried using quote but it does not help. Can you confirm if this 
is the right way to use quote ? See below: 


excludefolders: "{{ excludefolders + ' -o -name ' + item | quote | 
default('') }}"



On Wednesday, February 26, 2020 at 12:42:57 PM UTC+5:30, Stefan Hornburg 
(Racke) wrote:
>
> On 2/26/20 8:05 AM, Shifa Shaikh wrote: 
> > Below is my playbook: 
> > 
> > | 
> >    -set_fact: 
> >        excludefolders:"{{ excludefolders + ' -o -name ' + item | 
> default('') }}" 
> >      with_items:"{{ lookup('vars', 'EXCLUDE_' + Layer).split(',') }}" 
> > 
> > 
> >    -debug: 
> >        msg:"excludedfolder is {{ excludefolders }}" 
> > | 
> > 
> > 
> > I get the below output 
> > 
> > | 
> > ok:[10.0.17.113]=>{"msg":"excludedfolder is -o -name custom -o -name 
> tree -o -name log" 
> > | 
> > 
> > 
> > However i want the variable to have single quotes around item like 
> below: 
> > 
> > Expected output: 
> > 
> > | 
> > ok:[10.0.17.113]=>{"msg":"excludedfolder is -o -name 'custom' -o -name 
> 'tree' -o -name 'log'" 
> > | 
> > 
> > 
> > I tried to use escape charecter for single quotes but none of them 
> worked. Below is what  tried. 
> > 
> > | 
> >    -set_fact: 
> >        excludefolders:"{{ excludefolders + ' -o -name ' + \' + item + \' 
>  | default('') }}" 
> >      with_items:"{{ lookup('vars', 'EXCLUDE_' + Layer).split(',') }}" 
> > 
> > 
> >    -set_fact: 
> >        excludefolders:"{{ excludefolders + ' -o -name ' ~ \' + item ~ \' 
>  | default('') }}" 
> >      with_items:"{{ lookup('vars', 'EXCLUDE_' + Layer).split(',') }}" 
> > 
> > 
> >    -set_fact: 
> >        excludefolders:"{{ excludefolders + ' -o -name \''  + item +'\'' 
>  | default('') }}" 
> >      with_items:"{{ lookup('vars', 'EXCLUDE_' + Layer).split(',') }}" 
> > 
> > | 
> > 
>
> What about the quote filter? 
>
>
> https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#id8 
>
> Regards 
>          Racke 
>
> > 
> > 
> > -- 
> > 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/b857c17b-00f3-44bb-8fd8-4d08f597b6ce%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/ansible-project/b857c17b-00f3-44bb-8fd8-4d08f597b6ce%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/006c8253-7889-4d4f-b135-ada8a6a1833b%40googlegroups.com.

Reply via email to