Fixes
This commit is contained in:
parent
29d43b9ef0
commit
2c26c3a53e
|
@ -14,7 +14,7 @@ else:
|
||||||
DEFAULT_ST_CONFIG_LOCATION = '$HOME/.local/state/syncthing/config.xml'
|
DEFAULT_ST_CONFIG_LOCATION = '$HOME/.local/state/syncthing/config.xml'
|
||||||
|
|
||||||
|
|
||||||
class SyncthingBase(AnsibleModule):
|
class SyncthingModule(AnsibleModule):
|
||||||
def _make_headers(self, target=None):
|
def _make_headers(self, target=None):
|
||||||
url = '{}{}{}{}'.format(
|
url = '{}{}{}{}'.format(
|
||||||
self.params['host'],
|
self.params['host'],
|
||||||
|
@ -87,23 +87,24 @@ class SyncthingBase(AnsibleModule):
|
||||||
return self._api_call(method='PATCH', data=data, target=target)
|
return self._api_call(method='PATCH', data=data, target=target)
|
||||||
|
|
||||||
def exit_json(self):
|
def exit_json(self):
|
||||||
super().exit_json(**self.module.result)
|
super().exit_json(**self.result)
|
||||||
def fail_json(self, msg=""):
|
def fail_json(self, msg=""):
|
||||||
super().fail_json(msg, **self.module.result)
|
super().fail_json(msg, **self.result)
|
||||||
|
|
||||||
def __init__(self, api_url='/', module_args=None, supports_check_mode=True):
|
def __init__(self, api_url='/', argument_spec=None, supports_check_mode=True):
|
||||||
module_args_temp = url_argument_spec()
|
self.api_url = api_url
|
||||||
module_args_temp.update(dict(
|
argument_spec_temp = url_argument_spec()
|
||||||
|
argument_spec_temp.update(dict(
|
||||||
host=dict(type='str', default='http://127.0.0.1:8384'),
|
host=dict(type='str', default='http://127.0.0.1:8384'),
|
||||||
unix_socket=dict(type='str', required=False),
|
unix_socket=dict(type='str', required=False),
|
||||||
api_key=dict(type='str', required=False, no_log=True),
|
api_key=dict(type='str', required=False, no_log=True),
|
||||||
config_file=dict(type='str', required=False),
|
config_file=dict(type='str', required=False),
|
||||||
timeout=dict(type='int', default=30),
|
timeout=dict(type='int', default=30),
|
||||||
))
|
))
|
||||||
if module_args is None:
|
if argument_spec is None:
|
||||||
module_args = {}
|
argument_spec = {}
|
||||||
module_args_temp.update(module_args)
|
argument_spec_temp.update(argument_spec)
|
||||||
super().__init__(module_args=module_args_temp, supports_check_mode=True)
|
super().__init__(argument_spec=argument_spec_temp, supports_check_mode=True)
|
||||||
|
|
||||||
# Auto-configuration: Try to fetch API key from filesystem
|
# Auto-configuration: Try to fetch API key from filesystem
|
||||||
if not self.params['api_key']:
|
if not self.params['api_key']:
|
||||||
|
|
|
@ -78,8 +78,7 @@ response:
|
||||||
type: dict
|
type: dict
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from ansible.collections.syncthing.plugins.module_utils.syncthing_api \
|
from ansible_collections.community.syncthing.plugins.module_utils.syncthing_api import SyncthingModule
|
||||||
import SyncthingModule
|
|
||||||
|
|
||||||
# Returns an object of a new device
|
# Returns an object of a new device
|
||||||
def create_device(params):
|
def create_device(params):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user