get_url: return no change in check mode when checksum matches (#53070)

Signed-off-by: Tony Finch <dot@dotat.at>
pull/53173/head
Tony Finch 6 years ago committed by John R Barker
parent 00efa26cdb
commit ccad79d162

@ -566,12 +566,6 @@ def main():
filename = url_filename(info['url'])
dest = os.path.join(dest, filename)
# If the remote URL exists, we're done with check mode
if module.check_mode:
os.remove(tmpsrc)
result['changed'] = True
module.exit_json(msg=info.get('msg', ''), **result)
# raise an error if there is no tmpsrc file
if not os.path.exists(tmpsrc):
os.remove(tmpsrc)
@ -599,6 +593,13 @@ def main():
os.remove(tmpsrc)
module.fail_json(msg="Destination %s is not writable" % (os.path.dirname(dest)), **result)
if module.check_mode:
if os.path.exists(tmpsrc):
os.remove(tmpsrc)
result['changed'] = ('checksum_dest' not in result or
result['checksum_src'] != result['checksum_dest'])
module.exit_json(msg=info.get('msg', ''), **result)
backup_file = None
if result['checksum_src'] != result['checksum_dest']:
try:

@ -268,6 +268,19 @@
that:
- result is not changed
- name: test checksum match in check mode
get_url:
url: 'https://{{ httpbin_host }}/get'
dest: '{{ remote_tmp_dir }}/test'
checksum: 'sha256:7036ede810fad2b5d2e7547ec703cae8da61edbba43c23f9d7203a0239b765c4.'
check_mode: True
register: result
- name: Assert that check mode was green
assert:
that:
- result is not changed
# https://github.com/ansible/ansible/issues/27617
- name: set role facts

Loading…
Cancel
Save