diff --git a/bundles/rspamd/files/ip_whitelist.map b/bundles/rspamd/files/ip_whitelist.map deleted file mode 100644 index 74b0d95..0000000 --- a/bundles/rspamd/files/ip_whitelist.map +++ /dev/null @@ -1,3 +0,0 @@ -% for ip in sorted(node.metadata.get('rspamd/ignore_spam_check_for_ips', set())): -${ip} -% endfor diff --git a/bundles/rspamd/items.py b/bundles/rspamd/items.py index 2b35a17..e160931 100644 --- a/bundles/rspamd/items.py +++ b/bundles/rspamd/items.py @@ -26,7 +26,9 @@ directories = { files = { '/etc/rspamd/local.d/ip_whitelist.map': { - 'content_type': 'mako', + 'content': '\n'.join( + sorted(node.metadata.get('rspamd/ip_whitelist')) + ) + '\n', 'triggers': { 'svc_systemd:rspamd:restart', }, diff --git a/bundles/rspamd/metadata.py b/bundles/rspamd/metadata.py index 0e6d787..472aefd 100644 --- a/bundles/rspamd/metadata.py +++ b/bundles/rspamd/metadata.py @@ -1,3 +1,5 @@ +from ipaddress import ip_interface + defaults = { 'apt': { 'packages': { @@ -20,6 +22,21 @@ defaults = { }, 'rspamd': { 'web_password': repo.vault.password_for(node.name + ' rspamd web password'), - 'ignore_spam_check_for_ips': [], + 'ip_whitelist': [], }, } + + +@metadata_reactor.provides( + 'rspamd/ip_whitelist', +) +def ignored_ips(metadata): + return { + 'rspamd': { + 'ip_whitelist': { + str(ip_interface(network['ipv4']).ip) + for other_node in repo.nodes + for network in other_node.metadata.get('network').values() + } + }, + }