How to Copy Files Between Two Nodes Using Ansible


If you need to copy files between two (2) nodes, using Ansible, then you can do the following:

This solution uses the synchronize module, specifically using the delegate_to:source-server keywords.

- hosts: serverB
  tasks:    
   - name: Copy Remote-To-Remote (from serverA to serverB)
     synchronize: src=/copy/from_serverA dest=/copy/to_serverB
     delegate_to: serverA