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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3c491483-c408-4176-98dd-09a3bed1b47e%40googlegroups.com.

Reply via email to