From 4c9f9973ddeb9b538d5003c266a18e9acd2b5457 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Sun, 20 Mar 2016 07:34:59 -0700 Subject: [PATCH] If file attribs are specified set them even if file already exists. Fixes #11821 --- lib/ansible/modules/network/basics/get_url.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/network/basics/get_url.py b/lib/ansible/modules/network/basics/get_url.py index 5e2fed2fa20..d79cfe2b133 100644 --- a/lib/ansible/modules/network/basics/get_url.py +++ b/lib/ansible/modules/network/basics/get_url.py @@ -253,7 +253,6 @@ def extract_filename_from_headers(headers): # main def main(): - argument_spec = url_argument_spec() argument_spec.update( url = dict(required=True), @@ -310,7 +309,6 @@ def main(): except ValueError: module.fail_json(msg="The checksum parameter has to be in format :") - if not dest_is_dir and os.path.exists(dest): checksum_mismatch = False @@ -326,7 +324,15 @@ def main(): # Not forcing redownload, unless checksum does not match if not force and not checksum_mismatch: - module.exit_json(msg="file already exists", dest=dest, url=url, changed=False) + # allow file attribute changes + module.params['path'] = dest + file_args = module.load_file_common_arguments(module.params) + file_args['path'] = dest + changed = module.set_fs_attributes_if_different(file_args, False) + + if changed: + module.exit_json(msg="file already exists but file attributes changed", dest=dest, url=url, changed=changed) + module.exit_json(msg="file already exists", dest=dest, url=url, changed=changed) # If the file already exists, prepare the last modified time for the # request.