Adding support for Apache 2.4 on Ubuntu 14.04

- Adding confext to virtualhost names.
- Renaming the default config file for Ubuntu (000-default.conf).
- Adding ability to use "Require all granted".
This commit is contained in:
Berry Langerak 2014-10-01 10:35:53 +02:00
parent 67b8518e47
commit b8fe242d35
4 changed files with 40 additions and 10 deletions

View File

@ -1,3 +1,5 @@
{% from "apache/map.jinja" import apache with context %}
{% if grains['os_family']=="Debian" %} {% if grains['os_family']=="Debian" %}
include: include:
@ -17,24 +19,21 @@ extend:
module: module:
- order: 425 - order: 425
a2dissite 000-default: a2dissite 000-default{{ apache.confext }}:
cmd.run: cmd.run:
- order: 225 - onlyif: test -f /etc/apache2/sites-enabled/000-default{{ apache.confext }}
- onlyif: ls /etc/apache2/sites-enabled/000-default
- watch_in: - watch_in:
- module: apache-reload - module: apache-reload
- require: - require:
- pkg: apache - pkg: apache
/etc/apache2/sites-available/default: /etc/apache2/sites-available/{{ apache.default_site }}:
file.absent: file.absent:
- order: 230
- require: - require:
- pkg: apache - pkg: apache
/etc/apache2/sites-available/default-ssl: /etc/apache2/sites-available/{{ apache.default_site_ssl }}:
file.absent: file.absent:
- order: 230
- require: - require:
- pkg: apache - pkg: apache

View File

@ -8,8 +8,11 @@
'vhostdir': '/etc/apache2/sites-available', 'vhostdir': '/etc/apache2/sites-available',
'confdir': '/etc/apache2/conf.d', 'confdir': '/etc/apache2/conf.d',
'confext': '', 'confext': '',
'default_site': 'default',
'default_site_ssl': 'default-ssl',
'logdir': '/var/log/apache2', 'logdir': '/var/log/apache2',
'wwwdir': '/srv', 'wwwdir': '/srv',
'require_all': False,
}, },
'RedHat': { 'RedHat': {
'server': 'httpd', 'server': 'httpd',
@ -20,8 +23,11 @@
'vhostdir': '/etc/httpd/conf.d', 'vhostdir': '/etc/httpd/conf.d',
'confdir': '/etc/httpd/conf.d', 'confdir': '/etc/httpd/conf.d',
'confext': '.conf', 'confext': '.conf',
'default_site': 'default',
'default_site_ssl': 'default-ssl',
'logdir': '/var/log/httpd', 'logdir': '/var/log/httpd',
'wwwdir': '/var/www', 'wwwdir': '/var/www',
'require_all': False,
}, },
'FreeBSD': { 'FreeBSD': {
'server': 'apache22', 'server': 'apache22',
@ -32,7 +38,19 @@
'vhostdir': '/usr/local/etc/apache22/Includes', 'vhostdir': '/usr/local/etc/apache22/Includes',
'confdir': '/usr/local/etc/apache22/Includes', 'confdir': '/usr/local/etc/apache22/Includes',
'confext': '', 'confext': '',
'default_site': 'default',
'default_site_ssl': 'default-ssl',
'logdir': '/var/log/', 'logdir': '/var/log/',
'wwwdir': '/usr/local/www/apache22/', 'wwwdir': '/usr/local/www/apache22/',
'require_all': False,
}, },
}, merge=salt['pillar.get']('apache:lookup')) %} }, merge=salt['grains.filter_by']({
'14.04': {
'confext': '.conf',
'default_site': '000-default.conf',
'default_site_ssl': 'default-ssl.conf',
'require_all': True,
},
}, grain='lsb_distrib_release', merge=salt['pillar.get']('apache:lookup'))) %}

View File

@ -1,5 +1,7 @@
{# Define default values here so the template below can just focus on layout #} {# Define default values here so the template below can just focus on layout #}
{% from "apache/map.jinja" import apache with context %}
{% set sitename = site.get('ServerName', id) %} {% set sitename = site.get('ServerName', id) %}
{% set vals = { {% set vals = {
'interface': site.get('interface', '*'), 'interface': site.get('interface', '*'),
'port': site.get('port', '80'), 'port': site.get('port', '80'),
@ -45,11 +47,20 @@
{% if site.get('DocumentRoot') != False %}DocumentRoot {{ vals.DocumentRoot }}{% endif %} {% if site.get('DocumentRoot') != False %}DocumentRoot {{ vals.DocumentRoot }}{% endif %}
{% if site.get('VirtualDocumentRoot') %}VirtualDocumentRoot {{ vals.VirtualDocumentRoot }}{% endif %} {% if site.get('VirtualDocumentRoot') %}VirtualDocumentRoot {{ vals.VirtualDocumentRoot }}{% endif %}
{% if site.get('DocumentRoot') != False %}
<Directory {{ vals.DocumentRoot }}>
{% if apache.require_all %}
Require all granted
{% endif %}
</Directory>
{% endif %}
{% for path, dir in site.get('Directory', {}).items() %} {% for path, dir in site.get('Directory', {}).items() %}
{% set dvals = { {% set dvals = {
'Options': dir.get('Options', vals.Directory.Options), 'Options': dir.get('Options', vals.Directory.Options),
'Order': dir.get('Order', vals.Directory.Order), 'Order': dir.get('Order', vals.Directory.Order),
'Allow': dir.get('Allow', vals.Directory.Allow), 'Allow': dir.get('Allow', vals.Directory.Allow),
'Require': dir.get('Require', vals.Directory.Require),
'AllowOverride': dir.get('AllowOverride', vals.Directory.AllowOverride), 'AllowOverride': dir.get('AllowOverride', vals.Directory.AllowOverride),
} %} } %}
@ -60,6 +71,7 @@
{% if dir.get('Order') != False %}Order {{ dvals.Order }}{% endif %} {% if dir.get('Order') != False %}Order {{ dvals.Order }}{% endif %}
{% if dir.get('Allow') != False %}Allow {{ dvals.Allow }}{% endif %} {% if dir.get('Allow') != False %}Allow {{ dvals.Allow }}{% endif %}
{% if dir.get('AllowOverride') != False %}AllowOverride {{ dvals.AllowOverride }}{% endif %} {% if dir.get('AllowOverride') != False %}AllowOverride {{ dvals.AllowOverride }}{% endif %}
{% if dir.get('Require') != False %}Require {{dvals.Require}}{% endif %}
{% if dir.get('Formula_Append') %} {% if dir.get('Formula_Append') %}
{{ dir.Formula_Append|indent(8) }} {{ dir.Formula_Append|indent(8) }}

View File

@ -49,8 +49,9 @@ apache:
# E.g.: /var/www/example.com # E.g.: /var/www/example.com
default: default:
Options: -Indexes FollowSymLinks Options: -Indexes FollowSymLinks
Order: allow,deny Order: allow,deny # For Apache < 2.4
Allow: from all Allow: from all # For apache < 2.4
Require: all granted # For apache > 2.4.
AllowOverride: None AllowOverride: None
Formula_Append: | Formula_Append: |
Additional config as a Additional config as a