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:40:52 -0700
commitb5cb3321d4175e71869c1f178a894781c33cf39b (patch)
tree65d3c2bc367dd8a6647e624ddcb0e0f81933711b
parent628f3fd624d318a1b16767e23a4d3ce7375089e3 (diff)
downloadansible-modules-core-b5cb3321d4175e71869c1f178a894781c33cf39b.tar.gz
If file attribs are specified set them even if file already exists.
Fixes #11821
-rw-r--r--network/basics/get_url.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/network/basics/get_url.py b/network/basics/get_url.py
index b0d27859..d2155256 100644
--- a/network/basics/get_url.py
+++ b/network/basics/get_url.py
@@ -192,7 +192,6 @@ def extract_filename_from_headers(headers):
# main
def main():
-
argument_spec = url_argument_spec()
argument_spec.update(
url = dict(required=True),
@@ -219,7 +218,15 @@ def main():
if not dest_is_dir and os.path.exists(dest):
if not force:
- 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.