bundles/nginx: support non-domain vhost names

This commit is contained in:
Franzi 2020-10-31 10:30:07 +01:00
parent 4873ec053e
commit 67c5c23194
Signed by: kunsi
GPG key ID: 12E3D2136B818350
2 changed files with 10 additions and 9 deletions

View file

@ -51,14 +51,14 @@ if node.metadata['nginx']['use_ssl_for_all_connections']:
}, },
} }
for domain, config in node.metadata.get('nginx', {}).get('vhosts', {}).items(): for vhost, config in node.metadata.get('nginx', {}).get('vhosts', {}).items():
files['/etc/nginx/sites/{}'.format(domain)] = { if not 'domain' in config:
config['domain'] = vhost
files['/etc/nginx/sites/{}'.format(vhost)] = {
'source': 'site_template', 'source': 'site_template',
'content_type': 'mako', 'content_type': 'mako',
'context': { 'context': config,
'domain': domain,
**config
},
'needs': set(), 'needs': set(),
'triggers': { 'triggers': {
'svc_systemd:nginx:restart', 'svc_systemd:nginx:restart',
@ -66,7 +66,7 @@ for domain, config in node.metadata.get('nginx', {}).get('vhosts', {}).items():
} }
if not 'webroot' in config: if not 'webroot' in config:
directories['/var/www/{}'.format(domain)] = config.get('webroot_config', {}) directories['/var/www/{}'.format(vhost)] = config.get('webroot_config', {})
if node.metadata['nginx']['use_ssl_for_all_connections']: if node.metadata['nginx']['use_ssl_for_all_connections']:
files['/etc/nginx/sites/{}'.format(domain)]['needs'].add('action:letsencrypt_update_certificates') files['/etc/nginx/sites/{}'.format(vhost)]['needs'].add('action:letsencrypt_update_certificates')

View file

@ -34,7 +34,8 @@ def letsencrypt(metadata):
domains = {} domains = {}
for domain in metadata.get('nginx/vhosts', {}).keys(): for vhost, config in metadata.get('nginx/vhosts', {}).items():
domain = config.get('domain', vhost)
domains[domain] = set() domains[domain] = set()
return { return {