ac7e71bf56
DocumentRoot: fallback to SiteName like templates
55 lines
1.6 KiB
Plaintext
55 lines
1.6 KiB
Plaintext
{% from "apache/map.jinja" import apache with context %}
|
|
|
|
include:
|
|
- apache
|
|
|
|
{% for id, site in salt['pillar.get']('apache:sites', {}).items() %}
|
|
{% set documentroot = site.get('DocumentRoot', '{0}/{1}'.format(apache.wwwdir, site.get('ServerName', id))) %}
|
|
|
|
{{ id }}:
|
|
file:
|
|
- managed
|
|
- name: {{ apache.vhostdir }}/{{ id }}{{ apache.confext }}
|
|
- source: {{ site.get('template_file', 'salt://apache/vhosts/standard.tmpl') }}
|
|
- template: {{ site.get('template_engine', 'jinja') }}
|
|
- context:
|
|
id: {{ id|json }}
|
|
site: {{ site|json }}
|
|
map: {{ apache|json }}
|
|
- require:
|
|
- pkg: apache
|
|
- watch_in:
|
|
- module: apache-reload
|
|
|
|
{% if site.get('DocumentRoot') != False %}
|
|
{{ id }}-documentroot:
|
|
file.directory:
|
|
- name: {{ documentroot }}
|
|
- makedirs: True
|
|
- user: {{ site.get('DocumentRootUser', apache.get('document_root_user'))|json }}
|
|
- group: {{ site.get('DocumentRootGroup', apache.get('document_root_group'))|json }}
|
|
- allow_symlink: True
|
|
{% endif %}
|
|
|
|
{% if grains.os_family == 'Debian' %}
|
|
{% if site.get('enabled', True) %}
|
|
a2ensite {{ id }}{{ apache.confext }}:
|
|
cmd.run:
|
|
- unless: test -f /etc/apache2/sites-enabled/{{ id }}{{ apache.confext }}
|
|
- require:
|
|
- file: /etc/apache2/sites-available/{{ id }}{{ apache.confext }}
|
|
- watch_in:
|
|
- module: apache-reload
|
|
{% else %}
|
|
a2dissite {{ id }}{{ apache.confext }}:
|
|
cmd.run:
|
|
- onlyif: test -f /etc/apache2/sites-enabled/{{ id }}{{ apache.confext }}
|
|
- require:
|
|
- file: /etc/apache2/sites-available/{{ id }}{{ apache.confext }}
|
|
- watch_in:
|
|
- module: apache-reload
|
|
{% endif %}
|
|
{% endif %}
|
|
|
|
{% endfor %}
|