Adds a thirsty=yes|no to the get_url module, such that if downloading a large file from the internet you can decide
whether to download it every time or not -- will replace only on change, or decide to not download. The default is thirsty=no which will not download every time by default.
This commit is contained in:
parent
23ec079661
commit
1af0a4c303
1 changed files with 9 additions and 0 deletions
9
get_url
9
get_url
|
@ -136,11 +136,20 @@ def main():
|
|||
argument_spec = dict(
|
||||
url = dict(required=True),
|
||||
dest = dict(required=True),
|
||||
thirsty = dict(default='no', choices=BOOLEANS)
|
||||
)
|
||||
)
|
||||
|
||||
url = module.params['url']
|
||||
dest = os.path.expanduser(module.params['dest'])
|
||||
thirsty = module.boolean(module.params['thirsty'])
|
||||
|
||||
if not thirsty:
|
||||
if os.path.exists(dest):
|
||||
module.exit_json(msg="file already exists", changed=False)
|
||||
if os.path.isdir(dest):
|
||||
module.fail_json(msg="non-thirsty mode needs a filename for a destination, not a directory")
|
||||
|
||||
|
||||
# download to tmpsrc
|
||||
tmpsrc, info = url_get(module, url, dest)
|
||||
|
|
Loading…
Reference in a new issue