From 517e4af2cf8a38f89b489fd93f6431616a6122e0 Mon Sep 17 00:00:00 2001 From: Josh Kuhn Date: Mon, 25 Nov 2013 12:27:58 -0500 Subject: [PATCH 1/2] Added -FF flag to rsync invocation in synchronize The `-FF` option causes rsync to look for files in the source directory named `.rsync-filter` and uses them to filter directories underneath them. If no `.rsync-filter` files are found, the behavior is identical to the command run without the -FF option. This flag does not sync the .rsync-filter files themselves. This change should be backwards compatible and not produce surprising behavior for users, since they are unlikely to create `.rsync-filter` files unintentionally. --- library/files/synchronize | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/files/synchronize b/library/files/synchronize index 9acc4d46628..947d5e3acf0 100644 --- a/library/files/synchronize +++ b/library/files/synchronize @@ -183,7 +183,7 @@ def main(): owner = module.params['owner'] group = module.params['group'] - cmd = '%s --delay-updates --compress --timeout=%s' % (rsync, rsync_timeout) + cmd = '%s --delay-updates -FF --compress --timeout=%s' % (rsync, rsync_timeout) if module.check_mode: cmd = cmd + ' --dry-run' if delete: From b1a6bc6e7fa0395d8888046b9ad41144abdba6db Mon Sep 17 00:00:00 2001 From: Josh Kuhn Date: Mon, 25 Nov 2013 15:10:59 -0500 Subject: [PATCH 2/2] Added note about .rsync-filter files, with example --- library/files/synchronize | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/library/files/synchronize b/library/files/synchronize index 947d5e3acf0..67e8f511510 100644 --- a/library/files/synchronize +++ b/library/files/synchronize @@ -109,6 +109,10 @@ notes: - The remote user for the dest path will always be the remote_user, not the sudo_user. - Expect that dest=~/x will be ~/x even if using sudo. + - To exclude files and directories from being synchronized, you may add + C(.rsync-filter) files to the source directory. + + author: Timothy Appnel ''' @@ -142,6 +146,11 @@ synchronize: src=some/relative/path dest=/some/absolute/path delete=yes # Synchronize using an alternate rsync command synchronize: src=some/relative/path dest=/some/absolute/path rsync_path="sudo rsync" + +# Example .rsync-filter file in the source directory +- var # exclude any path whose last part is 'var' +- /var # exclude any path starting with 'var' starting at the source directory ++ /var/conf # include /var/conf even though it was previously excluded '''