From 41bbe0dcbd19323331b813c9ba704ad84abc36db Mon Sep 17 00:00:00 2001 From: Mandar Kulkarni Date: Wed, 28 Jul 2021 15:11:25 -0700 Subject: [PATCH] Modifying output to be displayed based on feedback --- plugins/modules/synchronize.py | 13 +++++-------- .../integration/targets/synchronize/tasks/main.yml | 4 ++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/plugins/modules/synchronize.py b/plugins/modules/synchronize.py index b0fee74..eba9b12 100644 --- a/plugins/modules/synchronize.py +++ b/plugins/modules/synchronize.py @@ -8,7 +8,6 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type - DOCUMENTATION = r''' --- module: synchronize @@ -639,19 +638,17 @@ def main(): while '' in out_lines: out_lines.remove('') - result = dict(changed=changed, rc=rc, cmd=cmdstr) + result = dict(changed=changed, rc=rc, cmd=cmdstr, stdout_lines=out_lines, msg=out_clean) if quiet: - result['msg'] = "OUTPUT IS HIDDEN DUE TO 'quiet=true'" - result['stdout_lines'] = [] - else: - result['msg'] = out_clean - result['std_out'] = out_lines + changes = len(out_lines) - 1 if len(out_lines) >= 1 else 0 + result['msg'] = "%s files/directories have been synchronized" % changes if module._diff: - result['diff'] = {'prepare': out_clean} + result['diff'] = {'prepared': out_clean} return module.exit_json(**result) + if __name__ == '__main__': main() diff --git a/tests/integration/targets/synchronize/tasks/main.yml b/tests/integration/targets/synchronize/tasks/main.yml index 0fe2a3b..df13665 100644 --- a/tests/integration/targets/synchronize/tasks/main.yml +++ b/tests/integration/targets/synchronize/tasks/main.yml @@ -274,7 +274,7 @@ ignore_errors: true - assert: that: - - '''--quiet'' in sync_result.cmd' + - '''files/directories have been synchronized'' in sync_result.msg' - name: Cleanup file: state: absent @@ -290,7 +290,7 @@ ignore_errors: true - assert: that: - - '''--quiet'' not in sync_result.cmd' + - '''files/directories have been synchronized'' not in sync_result.msg' - name: Cleanup file: state: absent