2020-07-10 00:58:55 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import salt.utils.dictupdate
|
|
|
|
import salt.utils.dictdiffer
|
|
|
|
|
2021-01-17 17:43:56 +01:00
|
|
|
|
2020-07-10 00:58:55 +02:00
|
|
|
def config(name, verify, url, cfg):
|
|
|
|
ret = {'name': name,
|
2020-09-30 00:44:06 +02:00
|
|
|
'changes': {},
|
|
|
|
'result': True,
|
|
|
|
'comment': 'config is up to date'}
|
2020-07-10 00:58:55 +02:00
|
|
|
|
|
|
|
cfg = dict(cfg)
|
|
|
|
|
|
|
|
apikey = __salt__['syncthing.get_apikey']()
|
|
|
|
st_cfg = __salt__['syncthing.get_config'](url, verify, apikey)
|
|
|
|
|
|
|
|
cfg['gui']['apiKey'] = apikey
|
|
|
|
|
|
|
|
res_cfg = salt.utils.dictupdate.update(st_cfg, cfg, recursive_update=True, merge_lists=False)
|
|
|
|
|
|
|
|
## Return to managed to set result
|
|
|
|
__salt__['syncthing.set_config'](url, verify, apikey, res_cfg)
|
|
|
|
|
|
|
|
ret['changes'] = salt.utils.dictdiffer.deep_diff(st_cfg, res_cfg)
|
|
|
|
|
2020-09-30 00:44:06 +02:00
|
|
|
return ret
|