2013-09-03 21:28:00 +02:00
|
|
|
{% from "apache/map.jinja" import apache with context %}
|
2013-08-28 00:27:01 +02:00
|
|
|
|
|
|
|
include:
|
|
|
|
- apache
|
|
|
|
|
|
|
|
{% for id, site in salt['pillar.get']('apache:sites', {}).items() %}
|
2015-06-19 22:55:30 +02:00
|
|
|
{% set documentroot = site.get('DocumentRoot', '{0}/{1}'.format(apache.wwwdir, id)) %}
|
2013-08-28 00:27:01 +02:00
|
|
|
|
|
|
|
{{ id }}:
|
|
|
|
file:
|
|
|
|
- managed
|
2014-02-09 15:12:31 +01:00
|
|
|
- name: {{ apache.vhostdir }}/{{ id }}{{ apache.confext }}
|
2013-08-28 00:27:01 +02:00
|
|
|
- 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:
|
2014-01-04 12:59:39 +01:00
|
|
|
- module: apache-reload
|
2015-03-25 15:06:18 +01:00
|
|
|
|
2015-09-21 15:47:46 +02:00
|
|
|
{% if site.get('DocumentRoot') != False %}
|
2015-03-23 22:22:08 +01:00
|
|
|
{{ id }}-documentroot:
|
|
|
|
file.directory:
|
2015-05-31 20:17:25 +02:00
|
|
|
- unless: test -d {{ documentroot }}
|
|
|
|
- name: {{ documentroot }}
|
2015-03-23 23:53:45 +01:00
|
|
|
- makedirs: True
|
2015-09-21 15:47:46 +02:00
|
|
|
{% endif %}
|
2013-08-28 00:27:01 +02:00
|
|
|
|
|
|
|
{% if grains.os_family == 'Debian' %}
|
2015-08-25 07:50:58 +02:00
|
|
|
{% if site.get('enabled') %}
|
2014-10-28 15:13:13 +01:00
|
|
|
a2ensite {{ id }}{{ apache.confext }}:
|
2013-08-28 00:27:01 +02:00
|
|
|
cmd:
|
|
|
|
- run
|
2014-10-28 15:13:13 +01:00
|
|
|
- unless: test -f /etc/apache2/sites-enabled/{{ id }}{{ apache.confext }}
|
2013-08-28 00:27:01 +02:00
|
|
|
- require:
|
2014-10-28 15:13:13 +01:00
|
|
|
- file: /etc/apache2/sites-available/{{ id }}{{ apache.confext }}
|
2013-11-05 20:34:06 +01:00
|
|
|
- watch_in:
|
2014-01-04 23:46:47 +01:00
|
|
|
- module: apache-reload
|
2015-08-25 07:50:58 +02:00
|
|
|
{% else %}
|
|
|
|
a2dissite {{ id }}{{ apache.confext }}:
|
|
|
|
cmd:
|
|
|
|
- run
|
2015-09-25 09:34:28 +02:00
|
|
|
- onlyif: test -f /etc/apache2/sites-enabled/{{ id }}{{ apache.confext }}
|
2015-08-25 07:50:58 +02:00
|
|
|
- require:
|
|
|
|
- file: /etc/apache2/sites-available/{{ id }}{{ apache.confext }}
|
|
|
|
- watch_in:
|
|
|
|
- module: apache-reload
|
2013-08-28 00:27:01 +02:00
|
|
|
{% endif %}
|
2015-08-25 07:58:22 +02:00
|
|
|
{% endif %}
|
2013-08-28 00:27:01 +02:00
|
|
|
|
|
|
|
{% endfor %}
|