2020-08-30 09:36:48 +00:00
|
|
|
directories = {
|
|
|
|
'/etc/nginx/sites': {
|
|
|
|
'purge': True,
|
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:nginx:restart',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-04-13 07:52:26 +00:00
|
|
|
files = {
|
|
|
|
'/etc/nginx/nginx.conf': {
|
|
|
|
'content_type': 'mako',
|
|
|
|
'context': node.metadata['nginx'],
|
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:nginx:restart',
|
|
|
|
},
|
|
|
|
},
|
2020-06-01 11:35:54 +00:00
|
|
|
'/etc/nginx/sites/stub_status': {
|
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:nginx:restart',
|
|
|
|
},
|
|
|
|
},
|
2020-04-13 07:52:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
svc_systemd = {
|
|
|
|
'nginx': {
|
|
|
|
'needs': {
|
|
|
|
'pkg_apt:nginx',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2020-06-01 08:52:52 +00:00
|
|
|
|
2020-09-20 12:36:43 +00:00
|
|
|
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',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-06-01 08:52:52 +00:00
|
|
|
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
|
|
|
|
},
|
2020-09-20 12:36:43 +00:00
|
|
|
'needs': set(),
|
2020-06-01 08:52:52 +00:00
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:nginx:restart',
|
|
|
|
},
|
|
|
|
}
|
2020-09-20 12:36:43 +00:00
|
|
|
|
|
|
|
if node.metadata['nginx']['use_ssl_for_all_connections']:
|
|
|
|
files['/etc/nginx/sites/{}'.format(domain)]['needs'].add('action:letsencrypt_update_certificates')
|