blob: 4b7b0b33657a580140d85e97bfe34a3afe2e5d9b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
from ansible.plugins.action import ActionBase
import re
import yaml
from yaml.loader import SafeLoader
class ActionModule(ActionBase):
def run(self, tmp=None, task_vars=None):
if task_vars is None:
task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars)
result['changed'] = False
result['failed'] = False
error_msgs = []
### Compiling host configuration ######################################
config = {}
if 'syncthing' in task_vars:
config = {
'config_path': "",
'folders_to_create': [],
'packages': [],
'service': "syncthing",
'user_group': "syncthing",
}
if task_vars['ansible_distribution'] == 'FreeBSD':
config['config_dir'] = "/usr/local/etc/syncthing/"
config['data_dir'] = "/var/syncthing"
config['packages'] = ["syncthing"]
elif task_vars['ansible_distribution'] == 'Gentoo':
config['config_dir'] = "/var/lib/syncthing/.config/syncthing/"
config['data_dir'] = "/var/lib/syncthing"
config['packages'] = ["net-p2p/syncthing"]
else:
error_msgs.append(f"syncthing role does not support {task_vars['ansible_distribution']} hosts yet")
### Results compilation ##############################################
if error_msgs != []:
result['msg'] = ' ; '.join(error_msgs)
result['failed'] = True
result['ansible_facts'] = {
'syncthing_pre': config,
}
return result
|