From 9ff1a8f22d6fa086d817113808897a8fc4a35bb6 Mon Sep 17 00:00:00 2001 From: George Robinson Date: Wed, 25 May 2016 16:53:52 +0100 Subject: [PATCH] vhost_overwrite option for nginx.ng state --- nginx/ng/map.jinja | 6 ++++++ nginx/ng/vhosts_config.sls | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/nginx/ng/map.jinja b/nginx/ng/map.jinja index 30ac548..70afee7 100644 --- a/nginx/ng/map.jinja +++ b/nginx/ng/map.jinja @@ -14,6 +14,7 @@ 'vhost_available': '/etc/nginx/sites-available', 'vhost_enabled': '/etc/nginx/sites-enabled', 'vhost_use_symlink': True, + 'vhost_overwrite': True, 'pid_file': '/run/nginx.pid', }, 'CentOS': { @@ -24,6 +25,7 @@ 'vhost_available': '/etc/nginx/conf.d', 'vhost_enabled': '/etc/nginx/conf.d', 'vhost_use_symlink': False, + 'vhost_overwrite': True, 'pid_file': '/run/nginx.pid', 'rh_os_releasever': '$releasever', 'gpg_check': False, @@ -37,6 +39,7 @@ 'vhost_available': '/etc/nginx/conf.d', 'vhost_enabled': '/etc/nginx/conf.d', 'vhost_use_symlink': False, + 'vhost_overwrite': True, 'pid_file': '/run/nginx.pid', 'rh_os_releasever': '$releasever', 'gpg_check': False, @@ -50,6 +53,7 @@ 'vhost_available': '/etc/nginx/conf.d', 'vhost_enabled': '/etc/nginx/conf.d', 'vhost_use_symlink': False, + 'vhost_overwrite': True, 'pid_file': '/run/nginx.pid', 'gpg_check': True, 'gpg_key': 'http://download.opensuse.org/repositories/server:/http/openSUSE_13.2/repodata/repomd.xml.key' @@ -62,6 +66,7 @@ 'vhost_available': '/etc/nginx/sites-available', 'vhost_enabled': '/etc/nginx/sites-enabled', 'vhost_use_symlink': True, + 'vhost_overwrite': True, }, 'Gentoo': { 'package': 'www-servers/nginx', @@ -71,6 +76,7 @@ 'vhost_available': '/etc/nginx/sites-available', 'vhost_enabled': '/etc/nginx/sites-enabled', 'vhost_use_symlink': True, + 'vhost_overwrite': True, }, }, default='Debian' ), 'install_from_source': False, diff --git a/nginx/ng/vhosts_config.sls b/nginx/ng/vhosts_config.sls index fe806a1..f51b782 100644 --- a/nginx/ng/vhosts_config.sls +++ b/nginx/ng/vhosts_config.sls @@ -94,6 +94,10 @@ nginx_vhost_available_dir: - template: jinja - context: config: {{ settings.config|json() }} + {% if nginx.lookup.vhost_overwrite == False %} + - unless: + - test -e {{ vhost_curpath(vhost) }} + {% endif %} {% do vhost_states.append(conf_state_id) %} {% endif %}