From 9b9ea97706a446ca91e8b3887ee107f63b844198 Mon Sep 17 00:00:00 2001 From: Andrea Scarpino Date: Tue, 25 Oct 2016 06:38:14 +0200 Subject: [PATCH] maven_artifact: Allow to specify a custom timeout (#2526) --- .../extras/packaging/language/maven_artifact.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/extras/packaging/language/maven_artifact.py b/lib/ansible/modules/extras/packaging/language/maven_artifact.py index 1136f7aaaf..f79f3175cb 100644 --- a/lib/ansible/modules/extras/packaging/language/maven_artifact.py +++ b/lib/ansible/modules/extras/packaging/language/maven_artifact.py @@ -102,6 +102,12 @@ options: required: true default: present choices: [present,absent] + timeout: + description: + - Specifies a timeout in seconds for the connection attempt + required: false + default: 10 + version_added: '2.2' validate_certs: description: - If C(no), SSL certificates will not be validated. This should only be set to C(no) when no other option exists. @@ -240,12 +246,14 @@ class MavenDownloader: client = boto3.client('s3',aws_access_key_id=self.module.params.get('username', ''), aws_secret_access_key=self.module.params.get('password', '')) url_to_use = client.generate_presigned_url('get_object',Params={'Bucket':bucket_name,'Key':key_name},ExpiresIn=10) + req_timeout = self.module.params.get('timeout') + # Hack to add parameters in the way that fetch_url expects self.module.params['url_username'] = self.module.params.get('username', '') self.module.params['url_password'] = self.module.params.get('password', '') self.module.params['http_agent'] = self.module.params.get('user_agent', None) - response, info = fetch_url(self.module, url_to_use) + response, info = fetch_url(self.module, url_to_use, timeout=req_timeout) if info['status'] != 200: raise ValueError(failmsg + " because of " + info['msg'] + "for URL " + url_to_use) else: @@ -328,6 +336,7 @@ def main(): username = dict(default=None,aliases=['aws_secret_key']), password = dict(default=None, no_log=True,aliases=['aws_secret_access_key']), state = dict(default="present", choices=["present","absent"]), # TODO - Implement a "latest" state + timeout = dict(default=10, type='int'), dest = dict(type="path", default=None), validate_certs = dict(required=False, default=True, type='bool'), )