rsync module

A couple of thoughts that have been bubbling around my head following the many mentions of using rsync from within ansible to move sets of files from the management host to the destination host(s).

We can use rsync as a local command, working over its own ssh connection.

However we already have a (potential at least) ssh connection to the target, and ansible may also have the capability to promote the privileges at the target end up to root using sudo - a capability we do not easily have just within rsync.

rsync runs as a client on the local end, and invokes a server process on the remote end. There are magic options (--server and --sender) used to designate what the rsync binary should be doing - these are pretty much undocumented and probably things we aren't meant to be fiddling with (so, a challenge!).

Is there a way we can do that setup for rsync, so that we run rsync --server on the remote end, and hook it up to the output of rsync --sender at the local end in a way that is relatively portable across rsync versions etc, and gives us the ability to add rsync goodness to all the additional capabilities that the copy module has over using local command to invoke rsync?

Comments?

  Nigel.

+1 on this

For reference:

https://pypi.python.org/pypi/pyrsync/0.1.0

Great find! And it appears to support windows too.

If you are using controlmaster in your .ssh/config you would be
reusing the ansible connection (when using ssh transport).

But it wouldn't work out-of-the-box using paramiko or another connection type. That's why Nigel's implementation (or a python implementation of rsync as suggested) is essential.