From f9bd2d695d6dbb081934c4fbb3caec6c0fd6e220 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Tue, 10 Nov 2020 14:28:12 +0100 Subject: [PATCH] bundles/postfix: add SPAM BLOCKLISt for every non-private IP attached to the server --- bundles/postfix/metadata.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/bundles/postfix/metadata.py b/bundles/postfix/metadata.py index a44c4b3..023c8a8 100644 --- a/bundles/postfix/metadata.py +++ b/bundles/postfix/metadata.py @@ -20,10 +20,6 @@ defaults = { if node.has_bundle('postfixadmin'): defaults['icinga2_api']['postfix']['services'].update({ - 'SPAM BLOCKLIST': { - 'check_command': 'spam_blocklist', - # vars.ip will be filled using a metadata reactor - }, 'SMTP CONNECT': { 'check_command': 'check_smtp', }, @@ -42,17 +38,20 @@ else: @metadata_reactor def fill_icinga_spam_blocklist_check_with_hostname(metadata): - if not node.has_bundle('postfixadmin'): - raise DoNotRunAgain + checks = {} + + for variant, ips in repo.libs.tools.resolve_identifier(repo, node.name).items(): + for ip in ips: + if not ip.is_private: + checks[f'SPAM BLOCKLIST {ip}'] = { + 'check_command': 'check_rbl', + 'vars.ip': str(ip), + } return { 'icinga2_api': { 'postfix': { - 'services': { - 'SPAM BLOCKLIST': { - 'vars.ip': metadata.get('postfix/myhostname', metadata.get('hostname', node.hostname)), - }, - }, + 'services': checks, }, }, }