apache-formula/apache/vhosts/standard.sls

66 lines
1.9 KiB
Plaintext
Raw Normal View History

{% 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() %}
{% set documentroot = site.get('DocumentRoot', '{0}/{1}'.format(apache.wwwdir, site.get('ServerName', id))) %}
2013-08-28 00:27:01 +02:00
2018-09-11 12:52:30 +02:00
apache_vhosts_{{ id }}:
file.managed:
- 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:
- module: apache-reload
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% 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 }}
2015-11-17 04:16:24 +01:00
- allow_symlink: True
{% endif %}
2013-08-28 00:27:01 +02:00
{% if grains.os_family == 'Debian' %}
2015-11-16 11:43:44 +01:00
{% if site.get('enabled', True) %}
a2ensite {{ id }}{{ apache.confext }}:
cmd.run:
- unless: test -f /etc/apache2/sites-enabled/{{ id }}{{ apache.confext }}
2013-08-28 00:27:01 +02:00
- require:
- file: /etc/apache2/sites-available/{{ id }}{{ apache.confext }}
- watch_in:
- module: apache-reload
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
{% 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
- require_in:
- module: apache-restart
- module: apache-reload
- service: apache
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 %}