From 67e12a8bc25bd634beed85283904d51635292d74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Br=C3=A9fort?= Date: Tue, 28 Oct 2014 15:13:13 +0100 Subject: [PATCH 1/2] Fixed Apache 2.4 support and added support for Ubuntu 14.10. Replace require_all with use_require in map.jinja, we want to be able to use custom Require values. Remove uneeded Directory in standard.tmpl and add conditional and default value for Require. Fix bad filenames in standard.sls --- apache/map.jinja | 16 ++++++++++------ apache/vhosts/standard.sls | 6 +++--- apache/vhosts/standard.tmpl | 14 +++++--------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/apache/map.jinja b/apache/map.jinja index 2c7026a..74d62a1 100644 --- a/apache/map.jinja +++ b/apache/map.jinja @@ -12,7 +12,7 @@ 'default_site_ssl': 'default-ssl', 'logdir': '/var/log/apache2', 'wwwdir': '/srv', - 'require_all': False, + 'use_require': False, }, 'RedHat': { 'server': 'httpd', @@ -27,7 +27,7 @@ 'default_site_ssl': 'default-ssl', 'logdir': '/var/log/httpd', 'wwwdir': '/var/www', - 'require_all': False, + 'use_require': False, }, 'FreeBSD': { 'server': 'apache22', @@ -42,15 +42,19 @@ 'default_site_ssl': 'default-ssl', 'logdir': '/var/log/', 'wwwdir': '/usr/local/www/apache22/', - 'require_all': False, + 'use_require': False, }, }, merge=salt['grains.filter_by']({ '14.04': { 'confext': '.conf', 'default_site': '000-default.conf', 'default_site_ssl': 'default-ssl.conf', - 'require_all': True, + 'use_require': True, + }, + '14.10': { + 'confext': '.conf', + 'default_site': '000-default.conf', + 'default_site_ssl': 'default-ssl.conf', + 'use_require': True, }, }, grain='lsb_distrib_release', merge=salt['pillar.get']('apache:lookup'))) %} - - diff --git a/apache/vhosts/standard.sls b/apache/vhosts/standard.sls index 9650c70..28e7608 100644 --- a/apache/vhosts/standard.sls +++ b/apache/vhosts/standard.sls @@ -21,12 +21,12 @@ include: - module: apache-reload {% if grains.os_family == 'Debian' %} -a2ensite {{ id }}: +a2ensite {{ id }}{{ apache.confext }}: cmd: - run - - unless: test -f /etc/apache2/sites-enabled/{{ id }} + - unless: test -f /etc/apache2/sites-enabled/{{ id }}{{ apache.confext }} - require: - - file: {{ id }} + - file: /etc/apache2/sites-available/{{ id }}{{ apache.confext }} - watch_in: - module: apache-reload {% endif %} diff --git a/apache/vhosts/standard.tmpl b/apache/vhosts/standard.tmpl index 7d9cf1e..426b99b 100644 --- a/apache/vhosts/standard.tmpl +++ b/apache/vhosts/standard.tmpl @@ -27,6 +27,7 @@ 'Options': '-Indexes FollowSymLinks', 'Order': 'allow,deny', 'Allow': 'from all', + 'Require': 'all granted', 'AllowOverride': 'None', }, } %} @@ -47,14 +48,6 @@ {% if site.get('DocumentRoot') != False %}DocumentRoot {{ vals.DocumentRoot }}{% endif %} {% if site.get('VirtualDocumentRoot') %}VirtualDocumentRoot {{ vals.VirtualDocumentRoot }}{% endif %} - {% if site.get('DocumentRoot') != False %} - - {% if apache.require_all %} - Require all granted - {% endif %} - - {% endif %} - {% for path, dir in site.get('Directory', {}).items() %} {% set dvals = { 'Options': dir.get('Options', vals.Directory.Options), @@ -68,10 +61,13 @@ {% if dir.get('Options') != False %}Options {{ dvals.Options }}{% endif %} + {% if apache.use_require %} + {% if dir.get('Require') != False %}Require {{dvals.Require}}{% endif %} + {% else %} {% if dir.get('Order') != False %}Order {{ dvals.Order }}{% endif %} {% if dir.get('Allow') != False %}Allow {{ dvals.Allow }}{% endif %} + {% endif %} {% if dir.get('AllowOverride') != False %}AllowOverride {{ dvals.AllowOverride }}{% endif %} - {% if dir.get('Require') != False %}Require {{dvals.Require}}{% endif %} {% if dir.get('Formula_Append') %} {{ dir.Formula_Append|indent(8) }} From 3612927174699b55e167c8650f82bba5c12830b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Br=C3=A9fort?= Date: Tue, 28 Oct 2014 18:50:04 +0100 Subject: [PATCH 2/2] Fix default Options. --- apache/vhosts/standard.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apache/vhosts/standard.tmpl b/apache/vhosts/standard.tmpl index 426b99b..887a1a9 100644 --- a/apache/vhosts/standard.tmpl +++ b/apache/vhosts/standard.tmpl @@ -24,7 +24,7 @@ 'Directory_default': '{0}/{1}'.format(map.wwwdir, sitename), 'Directory': { - 'Options': '-Indexes FollowSymLinks', + 'Options': '-Indexes +FollowSymLinks', 'Order': 'allow,deny', 'Allow': 'from all', 'Require': 'all granted',