2020-08-30 09:36:48 +00:00
|
|
|
directories = {
|
|
|
|
'/etc/nginx/sites': {
|
|
|
|
'purge': True,
|
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:nginx:restart',
|
|
|
|
},
|
|
|
|
},
|
2020-11-13 12:35:02 +00:00
|
|
|
'/var/www': {},
|
2020-08-30 09:36:48 +00:00
|
|
|
}
|
|
|
|
|
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-10-31 12:00:38 +00:00
|
|
|
'/etc/nginx/fastcgi.conf': {
|
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:nginx:restart',
|
|
|
|
},
|
|
|
|
},
|
2020-06-01 11:35:54 +00:00
|
|
|
'/etc/nginx/sites/stub_status': {
|
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:nginx:restart',
|
|
|
|
},
|
|
|
|
},
|
2020-11-10 09:57:04 +00:00
|
|
|
'/usr/local/share/icinga/plugins/check_nginx_status': {
|
|
|
|
'mode': '0755',
|
|
|
|
},
|
2020-04-13 07:52:26 +00:00
|
|
|
}
|
|
|
|
|
2020-10-31 09:18:40 +00:00
|
|
|
actions = {
|
|
|
|
'nginx-generate-dhparam': {
|
|
|
|
'command': 'openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048',
|
|
|
|
'unless': 'test -f /etc/ssl/certs/dhparam.pem',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-04-13 07:52:26 +00:00
|
|
|
svc_systemd = {
|
|
|
|
'nginx': {
|
|
|
|
'needs': {
|
2020-10-31 09:18:40 +00:00
|
|
|
'action:nginx-generate-dhparam',
|
2020-04-13 07:52:26 +00:00
|
|
|
'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-10-31 09:30:07 +00:00
|
|
|
for vhost, config in node.metadata.get('nginx', {}).get('vhosts', {}).items():
|
|
|
|
if not 'domain' in config:
|
|
|
|
config['domain'] = vhost
|
|
|
|
|
|
|
|
files['/etc/nginx/sites/{}'.format(vhost)] = {
|
2020-06-01 08:52:52 +00:00
|
|
|
'source': 'site_template',
|
|
|
|
'content_type': 'mako',
|
2020-10-31 09:41:33 +00:00
|
|
|
'context': {
|
|
|
|
'vhost': vhost,
|
2020-10-31 12:00:38 +00:00
|
|
|
'php_version': node.metadata.get('php', {}).get('version', ''),
|
2020-10-31 09:41:33 +00:00
|
|
|
**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
|
|
|
|
2020-10-18 16:55:00 +00:00
|
|
|
if not 'webroot' in config:
|
2020-11-12 21:59:46 +00:00
|
|
|
directories['/var/www/{}'.format(vhost)] = {}
|
|
|
|
|
|
|
|
if node.has_bundle('zfs'):
|
|
|
|
directories['/var/www/{}'.format(vhost)]['needs'] = {
|
|
|
|
'bundle:zfs',
|
|
|
|
}
|
|
|
|
|
|
|
|
directories['/var/www/{}'.format(vhost)].update(config.get('webroot_config', {}))
|
2020-10-18 16:55:00 +00:00
|
|
|
|
2020-09-20 12:36:43 +00:00
|
|
|
if node.metadata['nginx']['use_ssl_for_all_connections']:
|
2020-10-31 09:30:07 +00:00
|
|
|
files['/etc/nginx/sites/{}'.format(vhost)]['needs'].add('action:letsencrypt_update_certificates')
|