[ansible] Copy multiple files with Ansible

Use the following source code for copy multiple files on your client machine.


 - name: Copy data to the client machine
   hosts: hostname
   become_method: sudo
   become_user: root
   become: true
   tasks: 
     # Copy twice as sometimes files get skipped (mostly only one file skipped from a folder if the folder does not exist)
     - name: Copy UFO-Server 
       copy:
         src: "source files path"
         dest: "destination file path"
         owner: root
         group: root
         mode: 0644
         backup: yes
       ignore_errors: true

Note:

If you are passing multiple paths by using variable then

src: "/root/{{ item }}"

If you are passing path by using a variable for different items then

src: "/root/{{ item.source_path }}"