Assuming the target (inventory_hostname) is A, the copy target is B and the controller is C.
Most solutions you’ll have found won’t work with become: yes, you can only use become on the target server, but no the ‘other server’, so using things like rsync+ssh://user@B:/home/ (where user is not root) won’t work. Even though that is probably the most common solution for sync from A to B while controller is C.
Delegation just changes the ‘target’ and which means that your play instead of doing a sync from C to A does C to B. There is no existing solution with the synchronize action that will handle a 3 way + become. You can at best do sync A to C and then C to B within a playbook.
Other alternatives:
- Install and run
rsyncserver (runs asroot) on B and usesynchronizefrom A withdest: rsync://user@B:/home - Setup /home as network share (if NFS, no root squash) and use
synchronizewith ‘local paths’ - Enable a root login from A to B and then
dest: rsync+ssh://B:/home