diff --git a/collection/plugins/modules/device.py b/collection/plugins/modules/device.py index 241f7bc..865fd44 100644 --- a/collection/plugins/modules/device.py +++ b/collection/plugins/modules/device.py @@ -121,11 +121,12 @@ def get_key_from_filesystem(module): # Fetch Syncthing configuration def remote_config(module, method='GET', config=None, result=None, device=None): + unix_socket = None + if 'unix_socket' in module.params: + unix_socket = module.params['unix_socket'] url, headers = make_headers( host=module.params['host'], - unix_socket=module.params['unix_socket'] - if 'unix_socket' in module.params - else None, + unix_socket=unix_socket, api_key= module.params['api_key'], device=device) data = config @@ -135,14 +136,10 @@ def remote_config(module, method='GET', config=None, result=None, device=None): if not result: result = {} - if 'unix_socket' in module.params: - resp, info = fetch_url( - module, unix_socket=url, data=data, headers=headers, - method=method, timeout=module.params['timeout']) - else: - resp, info = fetch_url( - module, url, data=data, headers=headers, - method=method, timeout=module.params['timeout']) + resp, info = fetch_url( + module, url=url, unix_socket=unix_socket, + data=data, headers=headers, + method=method, timeout=module.params['timeout']) if not info or info['status'] != 200: result['response'] = info