You can try this -

    - set_fact:
        excludefolders: "{{ excludefolders | default('') + ' -o -name ' +
item | default('') }}"
      with_items: "{{ lookup('vars', 'EXCLUDE_' + Layer).split(',') }}"

On Wed, Feb 26, 2020 at 12:00 PM Shifa Shaikh <[email protected]> wrote:

> I need to set_fact variable and contact to itself a list of items as below:
>
>     - set_fact:
>         excludefolders: "{{ excludefolders + ' -o -name ' + item |
> default('') }}"
>       with_items: "{{ lookup('vars', 'MY_' + Layer).split(',') }}"
>
>
> Getting error:
>
> FAILED! => {"msg": "The task includes an option with an undefined variable. 
> The error was: 'excludefolders' is undefined\n\nThe error appears to be in 
> '/app/test.yml': line 86, column 6, but may\nbe elsewhere in the file 
> depending on the exact syntax problem.\n\nThe offending line appears to 
> be:\n\n\n   - set_fact:\n     ^ here\n"}
>
>
> Is it neccessary to defined another set_fact before like below or is there
> a better solution to the issue ?
>
>     - set_fact:
>         excludefolders: ""
>
>
>     - set_fact:
>         excludefolders: "{{ excludefolders + ' -o -name ' + item |
> default('') }}"
>       with_items: "{{ lookup('vars', 'EXCLUDE_' + Layer).split(',') }}"
>
>
>
>
> --
> 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/3c491483-c408-4176-98dd-09a3bed1b47e%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/3c491483-c408-4176-98dd-09a3bed1b47e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Thanks,
Abhijeet Kasurde

-- 
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/CAFwWkHpRNuE13%3DXS7zzT773gR5_6gNtFgpkM0TpqHa%2BkFGv24g%40mail.gmail.com.

Reply via email to