- name: copy /etc/passwd, /etc/group, /etc/shadow files in /tmp folder hosts: web vars: mydir: - /etc/passwd - /etc/group - /etc/shadow myfile: - /tmp/folder1 - /tmp/folder2 - /tmp/folder3 tasks: - copy: src: "{{ item }}" dest: /tmp with_items: - "{{ mydir }}" - file: path: "{{ item }}" state: directory with_items: - "{{ myfile }}" - copy: src: /etc/passwd dest: "{{ item }}" with_items: - "{{ mydir }}"