2020-11-08 09:43:51 +00:00
|
|
|
from os import listdir
|
|
|
|
from os.path import join
|
|
|
|
|
2021-04-02 16:57:13 +00:00
|
|
|
repo.libs.tools.require_bundle(node, 'redis', 'rspamd does not work without a redis cache')
|
2021-02-07 20:09:39 +00:00
|
|
|
|
2020-11-08 09:43:51 +00:00
|
|
|
directories = {
|
|
|
|
'/etc/rspamd/local.d': {
|
|
|
|
'purge': True,
|
|
|
|
'needs': {
|
|
|
|
'pkg_apt:rspamd',
|
|
|
|
},
|
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:rspamd:restart',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'/etc/rspamd/override.d': {
|
|
|
|
'purge': True,
|
|
|
|
'needs': {
|
|
|
|
'pkg_apt:rspamd',
|
|
|
|
},
|
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:rspamd:restart',
|
|
|
|
},
|
|
|
|
},
|
2020-11-08 12:35:43 +00:00
|
|
|
'/var/lib/rspamd/dkim': {
|
|
|
|
'owner': '_rspamd',
|
|
|
|
'group': '_rspamd',
|
|
|
|
'mode': '0750',
|
2021-07-18 05:56:26 +00:00
|
|
|
'needs': {
|
|
|
|
'pkg_apt:rspamd',
|
|
|
|
},
|
2020-11-08 12:35:43 +00:00
|
|
|
},
|
2020-11-08 09:43:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
svc_systemd = {
|
|
|
|
'rspamd': {
|
|
|
|
'needs': {
|
|
|
|
'pkg_apt:rspamd',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'clamav-daemon': {
|
|
|
|
'needs': {
|
|
|
|
'pkg_apt:clamav',
|
|
|
|
'pkg_apt:clamav-daemon',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'clamav-freshclam': {
|
|
|
|
'needs': {
|
|
|
|
'pkg_apt:clamav-freshclam',
|
|
|
|
},
|
|
|
|
},
|
2021-09-06 07:11:36 +00:00
|
|
|
'rspamd-dmarc-report.timer': {
|
|
|
|
'needs': {
|
|
|
|
'file:/etc/systemd/system/rspamd-dmarc-report.service',
|
|
|
|
'file:/etc/systemd/system/rspamd-dmarc-report.timer',
|
|
|
|
},
|
|
|
|
},
|
2020-11-08 09:43:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
files = {
|
|
|
|
'/etc/rspamd/local.d/ip_whitelist.map': {
|
|
|
|
'content_type': 'mako',
|
|
|
|
},
|
2021-08-23 20:19:31 +00:00
|
|
|
'/usr/local/bin/telegraf-rspamd-plugin': {
|
|
|
|
'mode': '0755',
|
|
|
|
},
|
2021-09-06 07:11:36 +00:00
|
|
|
'/etc/systemd/system/rspamd-dmarc-report.timer': {
|
|
|
|
'content_type': 'mako',
|
|
|
|
'context': {
|
|
|
|
'hour': node.magic_number%24,
|
|
|
|
'minute': node.magic_number%60,
|
|
|
|
},
|
|
|
|
'triggers': {
|
|
|
|
'action:systemd-reload',
|
|
|
|
'svc_systemd:rspamd-dmarc-report.timer:restart',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'/etc/systemd/system/rspamd-dmarc-report.service': {
|
|
|
|
'triggers': {
|
|
|
|
'action:systemd-reload',
|
|
|
|
},
|
|
|
|
},
|
2020-11-08 09:43:51 +00:00
|
|
|
}
|
|
|
|
|
2020-11-08 12:35:43 +00:00
|
|
|
|
|
|
|
if 'dkim' in node.metadata.get('rspamd', {}):
|
2020-11-08 09:43:51 +00:00
|
|
|
for i in {'arc', 'dkim_signing'}:
|
|
|
|
files[f'/etc/rspamd/local.d/{i}.conf'] = {
|
|
|
|
'source': 'dkim.conf',
|
2020-11-08 12:16:00 +00:00
|
|
|
'content_type': 'mako',
|
|
|
|
'needs': {
|
|
|
|
'action:rspamd_generate_dkim_key',
|
|
|
|
},
|
2020-11-08 09:43:51 +00:00
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:rspamd:restart',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-07-17 14:08:42 +00:00
|
|
|
dkim_key = repo.libs.faults.ensure_fault_or_none(node.metadata['rspamd']['dkim'])
|
|
|
|
|
2020-12-18 05:41:05 +00:00
|
|
|
actions = {
|
|
|
|
'rspamd_assure_dkim_key_permissions': {
|
|
|
|
'command': 'chown _rspamd:_rspamd /var/lib/rspamd/dkim/*.key',
|
2024-04-28 19:40:35 +00:00
|
|
|
'unless': r'test -z "$(find /var/lib/rspamd/ -iname \"*.key\" \! -user _rspamd)"',
|
2020-12-18 05:41:05 +00:00
|
|
|
'needs': {
|
|
|
|
'action:rspamd_generate_dkim_key',
|
|
|
|
'directory:/var/lib/rspamd/dkim',
|
|
|
|
},
|
2020-11-08 12:16:00 +00:00
|
|
|
},
|
2020-12-18 05:41:05 +00:00
|
|
|
'rspamd_generate_dkim_key': {
|
2021-07-17 14:08:42 +00:00
|
|
|
'command': dkim_key.format_into('cd /var/lib/rspamd/dkim && /usr/bin/rspamadm dkim_keygen -s "{0}" -b 2048 -k "{0}.key" > "{0}.txt"'),
|
|
|
|
'unless': dkim_key.format_into('test -f "/var/lib/rspamd/dkim/{0}.key"'),
|
2020-12-18 05:41:05 +00:00
|
|
|
'needs': {
|
|
|
|
'directory:/var/lib/rspamd/dkim',
|
|
|
|
'pkg_apt:rspamd',
|
|
|
|
},
|
2020-12-18 07:21:56 +00:00
|
|
|
},
|
|
|
|
}
|
2020-11-08 12:16:00 +00:00
|
|
|
|
2021-09-06 07:28:30 +00:00
|
|
|
if 'password' in node.metadata.get('rspamd', {}):
|
2020-11-08 09:43:51 +00:00
|
|
|
files['/etc/rspamd/local.d/worker-controller.inc'] = {
|
|
|
|
'content_type': 'mako',
|
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:rspamd:restart',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
local_config_path = join(repo.path, 'bundles', 'rspamd', 'files', 'local.d')
|
|
|
|
for f in listdir(local_config_path):
|
|
|
|
files[f'/etc/rspamd/local.d/{f}'] = {
|
|
|
|
'source': f'local.d/{f}',
|
2021-09-06 07:11:36 +00:00
|
|
|
'content_type': 'mako',
|
2020-11-08 09:43:51 +00:00
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:rspamd:restart',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
override_config_path = join(repo.path, 'bundles', 'rspamd', 'files', 'override.d')
|
|
|
|
for f in listdir(override_config_path):
|
|
|
|
files[f'/etc/rspamd/override.d/{f}'] = {
|
|
|
|
'source': f'override.d/{f}',
|
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:rspamd:restart',
|
|
|
|
},
|
|
|
|
}
|