Adding support for Apache 2.4 on Ubuntu 14.04master
{% from "apache/map.jinja" import apache with context %} | |||||
{% if grains['os_family']=="Debian" %} | {% if grains['os_family']=="Debian" %} | ||||
include: | include: | ||||
module: | module: | ||||
- order: 425 | - order: 425 | ||||
a2dissite 000-default: | |||||
a2dissite 000-default{{ apache.confext }}: | |||||
cmd.run: | cmd.run: | ||||
- order: 225 | |||||
- onlyif: ls /etc/apache2/sites-enabled/000-default | |||||
- onlyif: test -f /etc/apache2/sites-enabled/000-default{{ apache.confext }} | |||||
- 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 | ||||
'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', | ||||
'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', | ||||
'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'))) %} | |||||
{# 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'), | ||||
{% 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), | ||||
} %} | } %} | ||||
{% 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) }} |
# E.g.: /var/www/example.com | # E.g.: /var/www/example.com | ||||
default: | default: | ||||
Options: -Indexes FollowSymLinks | Options: -Indexes FollowSymLinks | ||||
Order: allow,deny | |||||
Allow: from all | |||||
Order: allow,deny # For Apache < 2.4 | |||||
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 |