From c195dce07c11f50d7914ecd324108fa95e70b3e5 Mon Sep 17 00:00:00 2001 From: Mathieu Tarral Date: Tue, 25 Aug 2015 01:50:58 -0400 Subject: [PATCH 1/2] add an 'enabled' attribute for a site in pillar --- apache/vhosts/standard.sls | 9 +++++++++ pillar.example | 1 + 2 files changed, 10 insertions(+) diff --git a/apache/vhosts/standard.sls b/apache/vhosts/standard.sls index f65fd86..823d08f 100644 --- a/apache/vhosts/standard.sls +++ b/apache/vhosts/standard.sls @@ -28,6 +28,7 @@ include: - makedirs: True {% if grains.os_family == 'Debian' %} +{% if site.get('enabled') %} a2ensite {{ id }}{{ apache.confext }}: cmd: - run @@ -36,6 +37,14 @@ a2ensite {{ id }}{{ apache.confext }}: - file: /etc/apache2/sites-available/{{ id }}{{ apache.confext }} - watch_in: - module: apache-reload +{% else %} +a2dissite {{ id }}{{ apache.confext }}: + cmd: + - run + - require: + - file: /etc/apache2/sites-available/{{ id }}{{ apache.confext }} + - watch_in: + - module: apache-reload {% endif %} {% endfor %} diff --git a/pillar.example b/pillar.example index 1cd82b5..232d2a6 100644 --- a/pillar.example +++ b/pillar.example @@ -18,6 +18,7 @@ apache: template_file: salt://apache/vhosts/minimal.tmpl example.com: # must be unique; used as an ID declaration in Salt. + enabled: True template_file: salt://apache/vhosts/standard.tmpl # or redirect.tmpl or proxy.tmpl ####################### DEFAULT VALUES BELOW ############################ From a7fb2f89fc5d63f9affaaef98e406e8dcdd3cb1e Mon Sep 17 00:00:00 2001 From: Mathieu Tarral Date: Tue, 25 Aug 2015 01:58:22 -0400 Subject: [PATCH 2/2] add missing {% endif %} --- apache/vhosts/standard.sls | 1 + 1 file changed, 1 insertion(+) diff --git a/apache/vhosts/standard.sls b/apache/vhosts/standard.sls index 823d08f..cfcf7fa 100644 --- a/apache/vhosts/standard.sls +++ b/apache/vhosts/standard.sls @@ -46,5 +46,6 @@ a2dissite {{ id }}{{ apache.confext }}: - watch_in: - module: apache-reload {% endif %} +{% endif %} {% endfor %}