bundlewrap/bundles/nginx/items.py
Franziska Kunsmann 48cc865892
All checks were successful
bundlewrap/pipeline/head This commit looks good
bundles/nginx: make sure webroot directory exists
2020-10-18 18:55:00 +02:00

64 lines
1.7 KiB
Python

directories = {
'/etc/nginx/sites': {
'purge': True,
'triggers': {
'svc_systemd:nginx:restart',
},
},
}
files = {
'/etc/nginx/nginx.conf': {
'content_type': 'mako',
'context': node.metadata['nginx'],
'triggers': {
'svc_systemd:nginx:restart',
},
},
'/etc/nginx/sites/stub_status': {
'triggers': {
'svc_systemd:nginx:restart',
},
},
}
svc_systemd = {
'nginx': {
'needs': {
'pkg_apt:nginx',
},
},
}
if node.metadata['nginx']['use_ssl_for_all_connections']:
# TODO rework this to support specifying a certificate instead of
# relying on letsencrypt for the specific domain (for example to
# support wildcard certificates
assert node.has_bundle('letsencrypt'), 'nginx needs letsencrypt'
files['/etc/nginx/sites/000-port80.conf'] = {
'source': 'port80.conf',
'triggers': {
'svc_systemd:nginx:restart',
},
}
for domain, config in node.metadata.get('nginx', {}).get('vhosts', {}).items():
files['/etc/nginx/sites/{}'.format(domain)] = {
'source': 'site_template',
'content_type': 'mako',
'context': {
'domain': domain,
**config
},
'needs': set(),
'triggers': {
'svc_systemd:nginx:restart',
},
}
if not 'webroot' in config:
directories['/var/www/{}'.format(domain)] = config.get('webroot_config', {})
if node.metadata['nginx']['use_ssl_for_all_connections']:
files['/etc/nginx/sites/{}'.format(domain)]['needs'].add('action:letsencrypt_update_certificates')