From 25ccb98d498f799cb50a371226a53dae2bef56dc Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Mon, 25 Jan 2016 13:05:02 +0100 Subject: [PATCH] Add custom or 'prepared' diff field to synchronize module This PR depends on pull requeest ansible/ansible#14105 rsync has a custom diff output that cannot easily be expressed as `/usr/bin/diff before after` --- lib/ansible/modules/files/synchronize.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/files/synchronize.py b/lib/ansible/modules/files/synchronize.py index fd1d56338f8..5cbda1dc6a4 100644 --- a/lib/ansible/modules/files/synchronize.py +++ b/lib/ansible/modules/files/synchronize.py @@ -418,8 +418,14 @@ def main(): out_lines=out_clean.split('\n') while '' in out_lines: out_lines.remove('') - return module.exit_json(changed=changed, msg=out_clean, - rc=rc, cmd=cmdstr, stdout_lines=out_lines) + if module._diff: + diff = {'prepared': out_clean} + return module.exit_json(changed=changed, msg=out_clean, + rc=rc, cmd=cmdstr, stdout_lines=out_lines, + diff=diff) + else: + return module.exit_json(changed=changed, msg=out_clean, + rc=rc, cmd=cmdstr, stdout_lines=out_lines) # import module snippets from ansible.module_utils.basic import *