I am attempting to copy multiple template files to my unix machine. Issue is, I have multiple systems, so the templates are variablized based off the group_var file, app.yml. User parses the system_name to the ansible playbook which then gathers the details from app.yml. The templates then pick those variables. Then the templates should be copied to the destination. However, with my current code, only 1 of the two templates are copied over.
app.yml:
system1:
src: 'template/file1.j2'
dst: '/app/user/file1'
src: 'template/file2.j2'
dst: '/app/user/file2'
system2:
src: 'template/file1.j2'
dst: '/app/user/file1'
src: 'template/file2.j2'
dst: '/app/user/file2'
main.yml
- name: copy mutiple templates to destination with dictionary
template: src={{ item.src }} dst={{ item.dst }}
when: "hostgroup='user_input'"
with_items: '{{ system1 }}'
With the above, only 1 file is copied and not both. Please can someone point me in the right direction? I have used the following also as reference; https://riptutorial.com/ansible/example/22079/with-items---predefined-dictionary