From 41c474d12920264cf0ff25e2f87de894de8f2927 Mon Sep 17 00:00:00 2001 From: Bruce Pennypacker Date: Wed, 28 Aug 2013 14:16:57 +0000 Subject: [PATCH 1/2] added optional ignore_md5_mismatch parameter --- lib/ansible/runner/action_plugins/fetch.py | 8 +++++--- library/files/fetch | 7 +++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/ansible/runner/action_plugins/fetch.py b/lib/ansible/runner/action_plugins/fetch.py index e7afa7d955..20d3aa76a9 100644 --- a/lib/ansible/runner/action_plugins/fetch.py +++ b/lib/ansible/runner/action_plugins/fetch.py @@ -50,6 +50,8 @@ class ActionModule(object): flat = utils.boolean(flat) fail_on_missing = options.get('fail_on_missing', False) fail_on_missing = utils.boolean(fail_on_missing) + ignore_md5_mismatch = options.get('ignore_md5_mismatch', False) + ignore_md5_mismatch = utils.boolean(ignore_md5_mismatch) if source is None or dest is None: results = dict(failed=True, msg="src and dest are required") return ReturnData(conn=conn, result=results) @@ -112,10 +114,10 @@ class ActionModule(object): f.write(remote_data) f.close() new_md5 = utils.md5(dest) - if new_md5 != remote_md5: - result = dict(failed=True, md5sum=new_md5, msg="md5 mismatch", file=source, dest=dest) + if not ignore_md5_mismatch and new_md5 != remote_md5: + result = dict(failed=True, md5sum=new_md5, msg="md5 mismatch", file=source, dest=dest, remote_md5sum=remote_md5) return ReturnData(conn=conn, result=result) - result = dict(changed=True, md5sum=new_md5, dest=dest) + result = dict(changed=True, md5sum=new_md5, dest=dest, remote_md5sum=remote_md5) return ReturnData(conn=conn, result=result) else: result = dict(changed=False, md5sum=local_md5, file=source, dest=dest) diff --git a/library/files/fetch b/library/files/fetch index 30d07c22b2..32f4f548f4 100644 --- a/library/files/fetch +++ b/library/files/fetch @@ -34,6 +34,13 @@ options: required: false choices: [ "yes", "no" ] default: "no" + ignore_md5_mismatch: + version_added: "1.3" + description: + - Do not check the md5sum of the destination file. Useful if transferring files that may change during the transfer, such as log files. + required: false + choices: [ "yes", "no" ] + default: "no" flat: version_added: "1.2" description: From cf6a76c814b56b7f9a1b43fc7317aaeae1862393 Mon Sep 17 00:00:00 2001 From: Bruce Pennypacker Date: Wed, 28 Aug 2013 14:41:00 +0000 Subject: [PATCH 2/2] changed ignore_md5_mismatch to validate_md5 --- lib/ansible/runner/action_plugins/fetch.py | 6 +++--- library/files/fetch | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/ansible/runner/action_plugins/fetch.py b/lib/ansible/runner/action_plugins/fetch.py index 20d3aa76a9..6af14b279a 100644 --- a/lib/ansible/runner/action_plugins/fetch.py +++ b/lib/ansible/runner/action_plugins/fetch.py @@ -50,8 +50,8 @@ class ActionModule(object): flat = utils.boolean(flat) fail_on_missing = options.get('fail_on_missing', False) fail_on_missing = utils.boolean(fail_on_missing) - ignore_md5_mismatch = options.get('ignore_md5_mismatch', False) - ignore_md5_mismatch = utils.boolean(ignore_md5_mismatch) + validate_md5 = options.get('validate_md5', True) + validate_md5 = utils.boolean(validate_md5) if source is None or dest is None: results = dict(failed=True, msg="src and dest are required") return ReturnData(conn=conn, result=results) @@ -114,7 +114,7 @@ class ActionModule(object): f.write(remote_data) f.close() new_md5 = utils.md5(dest) - if not ignore_md5_mismatch and new_md5 != remote_md5: + if validate_md5 and new_md5 != remote_md5: result = dict(failed=True, md5sum=new_md5, msg="md5 mismatch", file=source, dest=dest, remote_md5sum=remote_md5) return ReturnData(conn=conn, result=result) result = dict(changed=True, md5sum=new_md5, dest=dest, remote_md5sum=remote_md5) diff --git a/library/files/fetch b/library/files/fetch index 32f4f548f4..800f25274c 100644 --- a/library/files/fetch +++ b/library/files/fetch @@ -34,13 +34,13 @@ options: required: false choices: [ "yes", "no" ] default: "no" - ignore_md5_mismatch: + validate_md5: version_added: "1.3" description: - - Do not check the md5sum of the destination file. Useful if transferring files that may change during the transfer, such as log files. + - Verify that the source and destination md5sums match after the files are fetched. required: false choices: [ "yes", "no" ] - default: "no" + default: "yes" flat: version_added: "1.2" description: