bundles/nginx/metadata.pybasic http check

This commit is contained in:
mwiegand 2022-09-05 13:48:54 +02:00
parent d8f0d49a64
commit 1e2e63405a
2 changed files with 23 additions and 4 deletions

View file

@ -24,6 +24,7 @@ def nginx(metadata):
'context': { 'context': {
'root': f"/var/www/{metadata.get('mailserver/autoconfig_hostname')}", '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): def autoconfig(metadata):
dns = {} dns = {}
for domain in metadata.get('mailserver/domains'): for domain in metadata.get('mailserver/domains'):
dns.update({ dns.update({
f'autoconfig.{domain}': { f'autoconfig.{domain}': {
@ -87,7 +88,7 @@ def autoconfig(metadata):
'SRV': {f"0 1 993 {metadata.get('mailserver/hostname')}."}, 'SRV': {f"0 1 993 {metadata.get('mailserver/hostname')}."},
}, },
}) })
return { return {
'dns': dns, 'dns': dns,
} }

View file

@ -1,5 +1,7 @@
from shlex import quote
from ipaddress import ip_interface from ipaddress import ip_interface
defaults = { defaults = {
'apt': { 'apt': {
'packages': { 'packages': {
@ -62,7 +64,7 @@ def includes(metadata):
) )
def vhosts(metadata): def vhosts(metadata):
vhosts = {} vhosts = {}
for name, config in metadata.get('nginx/vhosts').items(): for name, config in metadata.get('nginx/vhosts').items():
vhosts[name] = { vhosts[name] = {
'server_name': name, 'server_name': name,
@ -76,7 +78,7 @@ def vhosts(metadata):
'alias': '/var/lib/dehydrated/acme-challenges/', 'alias': '/var/lib/dehydrated/acme-challenges/',
}, },
} }
return { return {
'nginx': { 'nginx': {
'vhosts': vhosts, '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()
},
},
}