Question:
I’m trying multiple concatenation when preforming with_items
for the destination section.
Right now it looks like this:
1 2 3 4 5 |
- name: create app except+lookup copy: content="" dest="{{ dir.comp ~ '/config/con2dd/' ~ item.name ~ 'File.txt' }}" force=no group=devops owner=devops mode: 0755 with_items: ... |
I get:
1 2 3 4 5 6 7 8 9 10 11 12 |
We could be wrong, but this one looks like it might be an issue with missing quotes. Always quote template expression brackets when they start a value. For instance: with_items: - {{ foo }} Should be written as: with_items: - "{{ foo }}" |
Tried couple of approaches but none resulted something that’s working.
Is it possible to concat the variables with the strings?
Answer:
Don’t mix pure YAML and key=value syntaxes for parameters. And always use YAML syntax for complex arguments:
1 2 3 4 5 6 7 8 9 10 11 |
- name: create app except+lookup copy: content: "" dest: "{{ dir.comp }}/config/con2dd/{{ item.name }}File.txt" force: no group: devops owner: devops mode: 0755 with_items: ... |