Merge pull request #56 from thornycrackers/master

Create defaul vhost directories when DocumentRoot is not set
This commit is contained in:
Niels Abspoel 2015-06-17 16:11:29 +02:00
commit f6a0c84544
2 changed files with 4 additions and 5 deletions

View File

@ -43,7 +43,7 @@ Installs the mod_wsgi package and enables the Apache module.
``apache.vhosts.standard`` ``apache.vhosts.standard``
------------------------- -------------------------
Configures Apache name-based virtual hosts using data from Pillar. Configures Apache name-based virtual hosts and creates virtual host directories using data from Pillar.
Example Pillar: Example Pillar:

View File

@ -4,6 +4,7 @@ include:
- apache - apache
{% for id, site in salt['pillar.get']('apache:sites', {}).items() %} {% for id, site in salt['pillar.get']('apache:sites', {}).items() %}
{% set documentroot = site.get('DocumentRoot', '{0}/{1}'.format(apache.wwwdir, sitename)) %}
{{ id }}: {{ id }}:
file: file:
@ -20,13 +21,11 @@ include:
- watch_in: - watch_in:
- module: apache-reload - module: apache-reload
{% if 'DocumentRoot' in site %}
{{ id }}-documentroot: {{ id }}-documentroot:
file.directory: file.directory:
- unless: test -d {{ site.get('DocumentRoot') }} - unless: test -d {{ documentroot }}
- name: {{ site.get('DocumentRoot') }} - name: {{ documentroot }}
- makedirs: True - makedirs: True
{% endif %}
{% if grains.os_family == 'Debian' %} {% if grains.os_family == 'Debian' %}
a2ensite {{ id }}{{ apache.confext }}: a2ensite {{ id }}{{ apache.confext }}: