diff --git a/bundles/nginx/items.py b/bundles/nginx/items.py index 9833f83..193092c 100644 --- a/bundles/nginx/items.py +++ b/bundles/nginx/items.py @@ -51,14 +51,14 @@ if node.metadata['nginx']['use_ssl_for_all_connections']: }, } -for domain, config in node.metadata.get('nginx', {}).get('vhosts', {}).items(): - files['/etc/nginx/sites/{}'.format(domain)] = { +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)] = { 'source': 'site_template', 'content_type': 'mako', - 'context': { - 'domain': domain, - **config - }, + 'context': config, 'needs': set(), 'triggers': { 'svc_systemd:nginx:restart', @@ -66,7 +66,7 @@ for domain, config in node.metadata.get('nginx', {}).get('vhosts', {}).items(): } 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']: - files['/etc/nginx/sites/{}'.format(domain)]['needs'].add('action:letsencrypt_update_certificates') + files['/etc/nginx/sites/{}'.format(vhost)]['needs'].add('action:letsencrypt_update_certificates') diff --git a/bundles/nginx/metadata.py b/bundles/nginx/metadata.py index 2fe5815..4718a7e 100644 --- a/bundles/nginx/metadata.py +++ b/bundles/nginx/metadata.py @@ -34,7 +34,8 @@ def letsencrypt(metadata): 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() return {