diff --git a/bundles/mailserver-autoconfig/metadata.py b/bundles/mailserver-autoconfig/metadata.py index 793f156..b88fef7 100644 --- a/bundles/mailserver-autoconfig/metadata.py +++ b/bundles/mailserver-autoconfig/metadata.py @@ -24,6 +24,7 @@ def nginx(metadata): 'context': { 'root': f"/var/www/{metadata.get('mailserver/autoconfig_hostname')}", }, + 'check_path': '/mail/config-v1.1.xml', }, }, }, @@ -59,7 +60,7 @@ def letsencrypt(metadata): ) def autoconfig(metadata): dns = {} - + for domain in metadata.get('mailserver/domains'): dns.update({ f'autoconfig.{domain}': { @@ -87,7 +88,7 @@ def autoconfig(metadata): 'SRV': {f"0 1 993 {metadata.get('mailserver/hostname')}."}, }, }) - + return { 'dns': dns, } diff --git a/bundles/nginx/metadata.py b/bundles/nginx/metadata.py index 8c213b9..b1f0009 100644 --- a/bundles/nginx/metadata.py +++ b/bundles/nginx/metadata.py @@ -1,5 +1,7 @@ +from shlex import quote from ipaddress import ip_interface + defaults = { 'apt': { 'packages': { @@ -62,7 +64,7 @@ def includes(metadata): ) def vhosts(metadata): vhosts = {} - + for name, config in metadata.get('nginx/vhosts').items(): vhosts[name] = { 'server_name': name, @@ -76,7 +78,7 @@ def vhosts(metadata): 'alias': '/var/lib/dehydrated/acme-challenges/', }, } - + return { 'nginx': { 'vhosts': vhosts, @@ -111,3 +113,19 @@ def letsencrypt(metadata): }, }, } + + +@metadata_reactor.provides( + 'monitoring/services', +) +def monitoring(metadata): + return { + 'monitoring': { + 'services': { + f'HTTP {hostname}': { + 'vars.command': f"""/usr/bin/curl {quote(hostname + vhost.get('check_path', ''))} -IL --fail""" + } + for hostname, vhost in metadata.get('nginx/vhosts').items() + }, + }, + }