I have a fixed structure of vars that I need to use. Those files should already be on the destination server. There one specific case, where someone adds a template entry for file which is not on the destination server.
I would like to secure my playbook against this case. The biggest issue here for me is finding a way of either writing it in one with_subelements statement or iterating with_subelements over 2 tasks.
My vars structure
artifacts:
- name: demo
version: v1
templates:
- source: "/opt/source/file.txt"
destination: "/opt/destination/file.txt"
I would now like to iterate over this structure as in the next snippet:
- name: "Archive files"
synchronize:
src: "{{ item.1.destination }}"
dest: "/some/backup/dir/"
archive: yes
delegate_to: "{{ inventory_hostname }}"
when: item[1].destination.isfile
with_subelements:
- "{{ artifacts }}"
- templates