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': {
'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,
}

View file

@ -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()
},
},
}