fix use_proxy option in icinga2_host (#47671)

This commit is contained in:
Marcin 2019-01-14 12:03:36 +01:00 committed by René Moser
parent fd32760d7a
commit e7b91f331b
2 changed files with 7 additions and 3 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- icinga2_host - fixed the issue with not working ``use_proxy`` option of the module.

View file

@ -134,13 +134,16 @@ from ansible.module_utils.urls import fetch_url, url_argument_spec
class icinga2_api:
module = None
def __init__(self, module):
self.module = module
def call_url(self, path, data='', method='GET'):
headers = {
'Accept': 'application/json',
'X-HTTP-Method-Override': method,
}
url = self.module.params.get("url") + "/" + path
rsp, info = fetch_url(module=self.module, url=url, data=data, headers=headers, method=method)
rsp, info = fetch_url(module=self.module, url=url, data=data, headers=headers, method=method, use_proxy=self.module.params['use_proxy'])
body = ''
if rsp:
body = json.loads(rsp.read())
@ -248,8 +251,7 @@ def main():
variables = module.params["variables"]
try:
icinga = icinga2_api()
icinga.module = module
icinga = icinga2_api(module=module)
icinga.check_connection()
except Exception as e:
module.fail_json(msg="unable to connect to Icinga. Exception message: %s" % (e))