1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

IPA: Add option to specify timeout (#44572)

This fix allows user to specify idle timeout for fetch_url used
internally in IPA connection and post_json call.

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2018-08-26 23:18:46 +05:30 committed by GitHub
parent 50750c7363
commit 70d7513542
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -44,6 +44,7 @@ class IPAClient(object):
self.protocol = protocol
self.module = module
self.headers = None
self.timeout = module.params.get('ipa_timeout')
def get_base_url(self):
return '%s://%s/ipa' % (self.protocol, self.host)
@ -58,7 +59,7 @@ class IPAClient(object):
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'text/plain'}
try:
resp, info = fetch_url(module=self.module, url=url, data=to_bytes(data), headers=headers)
resp, info = fetch_url(module=self.module, url=url, data=to_bytes(data), headers=headers, timeout=self.timeout)
status_code = info['status']
if status_code not in [200, 201, 204]:
self._fail('login', info['msg'])
@ -104,7 +105,7 @@ class IPAClient(object):
data['params'] = [[name], item]
try:
resp, info = fetch_url(module=self.module, url=url, data=to_bytes(json.dumps(data)), headers=self.headers)
resp, info = fetch_url(module=self.module, url=url, data=to_bytes(json.dumps(data)), headers=self.headers, timeout=self.timeout)
status_code = info['status']
if status_code not in [200, 201, 204]:
self._fail(method, info['msg'])
@ -184,5 +185,6 @@ def ipa_argument_spec():
ipa_port=dict(type='int', default=443, fallback=(env_fallback, ['IPA_PORT'])),
ipa_user=dict(type='str', default='admin', fallback=(env_fallback, ['IPA_USER'])),
ipa_pass=dict(type='str', required=True, no_log=True, fallback=(env_fallback, ['IPA_PASS'])),
ipa_timeout=dict(type='int', default=10, fallback=(env_fallback, ['IPA_TIMEOUT'])),
validate_certs=dict(type='bool', default=True),
)

View file

@ -50,5 +50,13 @@ options:
- This should only set to C(no) used on personally controlled sites using self-signed certificates.
default: true
type: bool
ipa_timeout:
description:
- Specifies idle timeout (in seconds) for the connection.
- For bulk operations, you may want to increase this in order to avoid timeout from IPA server.
- If the value is not specified in the task, the value of environment variable C(IPA_TIMEOUT) will be used instead.
- If both the environment variable C(IPA_TIMEOUT) and the value are not specified in the task, then default value is set.
default: 10
version_added: 2.7
'''