From b51e442440cdba683d9cd590f03212d8ed43374a Mon Sep 17 00:00:00 2001 From: Alan McNea Date: Tue, 5 Nov 2013 19:32:03 +0000 Subject: [PATCH 1/5] Fixed bugs in standard.tmpl --- apache/vhosts/standard.tmpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apache/vhosts/standard.tmpl b/apache/vhosts/standard.tmpl index cb095b6..cf212cf 100644 --- a/apache/vhosts/standard.tmpl +++ b/apache/vhosts/standard.tmpl @@ -11,7 +11,7 @@ 'LogLevel': site.get('LogLevel', 'warn'), 'ErrorLog': site.get('ErrorLog', '{0}/{1}-error.log'.format(map.logdir, sitename)), - 'CustomLog': site.get('ErrorLog', '{0}/{1}-access.log'.format(map.logdir, sitename)), + 'CustomLog': site.get('CustomLog', '{0}/{1}-access.log'.format(map.logdir, sitename)), 'DocumentRoot': site.get('DocumentRoot', '{0}/{1}'.format(map.wwwdir, sitename)), @@ -40,8 +40,8 @@ {% set dvals = { 'Options': dir.get('Options', vals.Directory.Options), 'Order': dir.get('Order', vals.Directory.Order), - 'Allow': dir.get('Order', vals.Directory.Allow), - 'AllowOverride': dir.get('Order', vals.Directory.AllowOverride), + 'Allow': dir.get('Allow', vals.Directory.Allow), + 'AllowOverride': dir.get('AllowOverride', vals.Directory.AllowOverride), } %} {% if path == 'default' %}{% set path = vals.Directory_default %}{% endif %} From e34c476ea120680fa45909bac7f09f7af3f06b49 Mon Sep 17 00:00:00 2001 From: Alan McNea Date: Tue, 5 Nov 2013 19:32:49 +0000 Subject: [PATCH 2/5] Added DirectoryIndex, UseCanonicalName, and VirtualDocumentRoot properties to standard.tmpl --- apache/vhosts/standard.tmpl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apache/vhosts/standard.tmpl b/apache/vhosts/standard.tmpl index cf212cf..3d3f50b 100644 --- a/apache/vhosts/standard.tmpl +++ b/apache/vhosts/standard.tmpl @@ -9,11 +9,15 @@ 'ServerAdmin': site.get('ServerAdmin', 'webmaster@{0}'.format(sitename)), + 'DirectoryIndex': site.get('DirectoryIndex'), + 'UseCanonicalName': site.get('UseCanonicalName'), + 'LogLevel': site.get('LogLevel', 'warn'), 'ErrorLog': site.get('ErrorLog', '{0}/{1}-error.log'.format(map.logdir, sitename)), 'CustomLog': site.get('CustomLog', '{0}/{1}-access.log'.format(map.logdir, sitename)), 'DocumentRoot': site.get('DocumentRoot', '{0}/{1}'.format(map.wwwdir, sitename)), + 'VirtualDocumentRoot': site.get('VirtualDocumentRoot'), 'Directory_default': '{0}/{1}'.format(map.wwwdir, sitename), 'Directory': { @@ -30,11 +34,15 @@ {% if site.get('ServerAdmin') != False %}ServerAdmin {{ vals.ServerAdmin }}{% endif %} + {% if site.get('DirectoryIndex') %}DirectoryIndex {{ vals.DirectoryIndex }}{% endif %} + {% if site.get('UseCanonicalName') %}UseCanonicalName {{ vals.UseCanonicalName }}{% endif %} + {% if site.get('LogLevel') != False %}LogLevel {{ vals.LogLevel }}{% endif %} {% if site.get('ErrorLog') != False %}ErrorLog {{ vals.ErrorLog }}{% endif %} {% if site.get('CustomLog') != False %}CustomLog {{ vals.CustomLog }}{% endif %} {% if site.get('DocumentRoot') != False %}DocumentRoot {{ vals.DocumentRoot }}{% endif %} + {% if site.get('VirtualDocumentRoot') %}VirtualDocumentRoot {{ vals.VirtualDocumentRoot }}{% endif %} {% for path, dir in site.get('Directory', {}).items() %} {% set dvals = { From c863598ec75363bfbbb7411e9006906a686790ac Mon Sep 17 00:00:00 2001 From: Alan McNea Date: Tue, 5 Nov 2013 19:34:06 +0000 Subject: [PATCH 3/5] Moved apache-reload and apache-restart commands to init.sls and invoke apache-reload from standard.sls --- apache/debian_full.sls | 10 ++++------ apache/init.sls | 9 +++++++++ apache/vhosts/standard.sls | 4 +++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/apache/debian_full.sls b/apache/debian_full.sls index 0f90a3c..19fe76b 100644 --- a/apache/debian_full.sls +++ b/apache/debian_full.sls @@ -21,14 +21,12 @@ a2dissite 000-default: - require: - pkg: apache -apache-reload: - cmd.wait: - - name: service apache2 reload +extend: + apache-reload: - order: 420 -apache-restart: - cmd.wait: - - name: service apache2 restart +extend: + apache-restart: - order: 425 /etc/apache2/sites-available/default: diff --git a/apache/init.sls b/apache/init.sls index 313e085..007c859 100644 --- a/apache/init.sls +++ b/apache/init.sls @@ -8,3 +8,12 @@ apache: - running - name: {{ apache.service }} - enable: True + +apache-reload: + cmd.wait: + - name: service apache2 reload + +apache-restart: + cmd.wait: + - name: service apache2 restart + diff --git a/apache/vhosts/standard.sls b/apache/vhosts/standard.sls index f049226..841580b 100644 --- a/apache/vhosts/standard.sls +++ b/apache/vhosts/standard.sls @@ -18,7 +18,7 @@ include: - require: - pkg: apache - watch_in: - - service: apache + - cmd: apache-reload {% if grains.os_family == 'Debian' %} a2ensite {{ id }}: @@ -26,6 +26,8 @@ a2ensite {{ id }}: - run - require: - file: {{ id }} + - watch_in: + - cmd: apache-reload {% endif %} {% endfor %} From f153c78ba8f3cc61504cf75eb9ee59c1f0b6374c Mon Sep 17 00:00:00 2001 From: Alan McNea Date: Tue, 5 Nov 2013 20:05:28 +0000 Subject: [PATCH 4/5] Added apache include and requires to php5.sls and rewrite.sls --- apache/php5.sls | 1 + apache/rewrite.sls | 3 +++ 2 files changed, 4 insertions(+) diff --git a/apache/php5.sls b/apache/php5.sls index ac28e87..e68569b 100644 --- a/apache/php5.sls +++ b/apache/php5.sls @@ -2,6 +2,7 @@ include: - apt + - apache mod-php5: pkg.installed: diff --git a/apache/rewrite.sls b/apache/rewrite.sls index 51099f5..44e0153 100644 --- a/apache/rewrite.sls +++ b/apache/rewrite.sls @@ -2,11 +2,14 @@ include: - apt + - apache a2enmod rewrite: cmd.run: - unless: ls /etc/apache2/mods-enabled/rewrite.load - order: 225 + - require: + - pkg: apache - watch_in: - cmd: apache-restart From 92b167ffa851b6727081bff3a19e27dedc32b7ad Mon Sep 17 00:00:00 2001 From: Alan McNea Date: Tue, 5 Nov 2013 20:06:10 +0000 Subject: [PATCH 5/5] Added vhost_alias.sls for that apache mod --- apache/vhost_alias.sls | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 apache/vhost_alias.sls diff --git a/apache/vhost_alias.sls b/apache/vhost_alias.sls new file mode 100644 index 0000000..f970151 --- /dev/null +++ b/apache/vhost_alias.sls @@ -0,0 +1,16 @@ +{% if grains['os_family']=="Debian" %} + +include: + - apt + - apache + +a2enmod vhost_alias: + cmd.run: + - unless: ls /etc/apache2/mods-enabled/vhost_alias.load + - order: 225 + - require: + - pkg: apache + - watch_in: + - cmd: apache-restart + +{% endif %}