I have plays in a playbook to copy files to a remote host, then delete them at the end of the task list. This is the copy play:
- name: Copy files to host
copy:
src: “{{ item.src }}”
dest: /tmp
mode: u=rwx,g=rw,o=rw
with_items:
- { src: package1 }
- { src: file1 }
- { src: file2 }
tags: copy_files
package1 is changeable, from time-to-time. I’d like to add the name as a variable, then call the variable in both the copy and delete plays, so that I only have to change the package name once. How can I accomplish that? All of my attempts have failed.