From 07b2a9f9f5661eb1836d34f31ce3c78d5e07e3ec Mon Sep 17 00:00:00 2001 From: Cody Hiar Date: Sun, 31 May 2015 12:17:25 -0600 Subject: [PATCH 1/2] Create defaul vhost directories when DocumentRoot is not set --- apache/vhosts/standard.sls | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apache/vhosts/standard.sls b/apache/vhosts/standard.sls index 15efe20..4864e8c 100644 --- a/apache/vhosts/standard.sls +++ b/apache/vhosts/standard.sls @@ -4,6 +4,7 @@ include: - apache {% for id, site in salt['pillar.get']('apache:sites', {}).items() %} +{% set documentroot = site.get('DocumentRoot', '{0}/{1}'.format(apache.wwwdir, sitename)) %} {{ id }}: file: @@ -20,13 +21,11 @@ include: - watch_in: - module: apache-reload -{% if 'DocumentRoot' in site %} {{ id }}-documentroot: file.directory: - - unless: test -d {{ site.get('DocumentRoot') }} - - name: {{ site.get('DocumentRoot') }} + - unless: test -d {{ documentroot }} + - name: {{ documentroot }} - makedirs: True -{% endif %} {% if grains.os_family == 'Debian' %} a2ensite {{ id }}{{ apache.confext }}: From 45de7301a7f0d813114ca9db7e5036a27a45dedc Mon Sep 17 00:00:00 2001 From: Cody Hiar Date: Mon, 1 Jun 2015 19:16:24 -0600 Subject: [PATCH 2/2] Updated README to note that directories are created when using apache.vhosts.standard --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index d56db1a..56cc636 100644 --- a/README.rst +++ b/README.rst @@ -43,7 +43,7 @@ Installs the mod_wsgi package and enables the Apache module. ``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: