summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <toshio@fedoraproject.org>2016-03-20 07:34:59 -0700
committerToshio Kuratomi <toshio@fedoraproject.org>2016-03-20 07:36:06 -0700
commitd71b9bae893e5cb860eb7717af93d00363b3890c (patch)
tree185e696548dc62c51a8395457049181aed3e9b20
parentfaf2bea527efe11bb70375bea1485d09669e8c44 (diff)
downloadansible-modules-core-d71b9bae893e5cb860eb7717af93d00363b3890c.tar.gz
If file attribs are specified set them even if file already exists.
Fixes #11821
-rw-r--r--network/basics/get_url.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/network/basics/get_url.py b/network/basics/get_url.py
index 87d0573e..e762a7c6 100644
--- a/network/basics/get_url.py
+++ b/network/basics/get_url.py
@@ -254,7 +254,6 @@ def extract_filename_from_headers(headers):
# main
def main():
-
argument_spec = url_argument_spec()
argument_spec.update(
url = dict(required=True),
@@ -311,7 +310,6 @@ def main():
except ValueError:
module.fail_json(msg="The checksum parameter has to be in format <algorithm>:<checksum>")
-
if not dest_is_dir and os.path.exists(dest):
checksum_mismatch = False
@@ -327,7 +325,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.