From 9c9050595d80fff0d79723c65988b0292535b237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20B=C3=A9rtoli?= Date: Sun, 23 Apr 2017 14:37:26 -0300 Subject: [PATCH 1/3] Remove duplicated ID (fixes #179) --- apache/config.sls | 7 ------- apache/init.sls | 6 +++++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/apache/config.sls b/apache/config.sls index 4691f8e..677bd6c 100644 --- a/apache/config.sls +++ b/apache/config.sls @@ -15,13 +15,6 @@ include: - context: apache: {{ apache }} -{{ apache.vhostdir }}: - file.directory: - - require: - - pkg: apache - - watch_in: - - service: apache - {% if grains['os_family']=="Debian" %} /etc/apache2/envvars: file.managed: diff --git a/apache/init.sls b/apache/init.sls index c3e170e..becb3d6 100644 --- a/apache/init.sls +++ b/apache/init.sls @@ -16,7 +16,11 @@ apache: {{ apache.vhostdir }}: file.directory: - - makedirs: True + - makedirs: True + - require: + - pkg: apache + - watch_in: + - service: apache # The following states are inert by default and can be used by other states to # trigger a restart or reload as needed. From ffac9b2381ee15f65dc2ab38e546329234bd0b23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20B=C3=A9rtoli?= Date: Sun, 23 Apr 2017 14:38:17 -0300 Subject: [PATCH 2/3] Added minimal template (fixes #34) --- apache/vhosts/minimal.tmpl | 30 ++++++++++++++++++++++++++++++ pillar.example | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 apache/vhosts/minimal.tmpl diff --git a/apache/vhosts/minimal.tmpl b/apache/vhosts/minimal.tmpl new file mode 100644 index 0000000..d2243c7 --- /dev/null +++ b/apache/vhosts/minimal.tmpl @@ -0,0 +1,30 @@ +{# Define default values here so the template below can just focus on layout #} +{%- set sitename = site.get('ServerName', id) -%} + +{%- set vals = { + 'interfaces': site.get('interface', '*').split(), + 'port': site.get('port', '80'), + + 'ServerName': sitename, + 'ServerAlias': site.get('ServerAlias', 'www.{0}'.format(sitename)), + + 'ServerAdmin': site.get('ServerAdmin', 'webmaster@{0}'.format(sitename)), + + 'LogLevel': site.get('LogLevel', 'warn'), + 'ErrorLog': site.get('ErrorLog', '{0}/{1}-error.log'.format(map.logdir, sitename)), + 'CustomLog': site.get('CustomLog', '{0}/{1}-access.log'.format(map.logdir, sitename)), + + 'DocumentRoot': site.get('DocumentRoot', '{0}/{1}'.format(map.wwwdir, sitename)) +} -%} + + + ServerName {{ vals.ServerName }} + {% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %} + {% if site.get('ServerAdmin') != False %}ServerAdmin {{ vals.ServerAdmin }}{% endif %} + + {% if site.get('DocumentRoot') != False -%}DocumentRoot {{ vals.DocumentRoot }}{% endif %} + + {% if site.get('LogLevel') != False -%}LogLevel {{ vals.LogLevel }}{% endif %} + {% if site.get('ErrorLog') != False -%}ErrorLog {{ vals.ErrorLog }}{% endif %} + {% if site.get('CustomLog') != False -%}CustomLog {{ vals.CustomLog }} {{ vals.LogFormat }}{% endif %} + diff --git a/pillar.example b/pillar.example index 17539bc..8969a2c 100644 --- a/pillar.example +++ b/pillar.example @@ -41,7 +41,7 @@ apache: example.com: # must be unique; used as an ID declaration in Salt. enabled: True - template_file: salt://apache/vhosts/standard.tmpl # or redirect.tmpl or proxy.tmpl + template_file: salt://apache/vhosts/standard.tmpl # or minimal.tmpl or redirect.tmpl or proxy.tmpl ####################### DEFAULT VALUES BELOW ############################ # NOTE: the values below are simply default settings that *can* be From a7f66b63449edab5a4c1b7c4b2851d53fc95c485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20B=C3=A9rtoli?= Date: Mon, 24 Apr 2017 15:33:44 -0300 Subject: [PATCH 3/3] Move vhostdir `to config.sls` --- apache/config.sls | 8 ++++++++ apache/init.sls | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apache/config.sls b/apache/config.sls index 677bd6c..6a29683 100644 --- a/apache/config.sls +++ b/apache/config.sls @@ -15,6 +15,14 @@ include: - context: apache: {{ apache }} +{{ apache.vhostdir }}: + file.directory: + - makedirs: True + - require: + - pkg: apache + - watch_in: + - service: apache + {% if grains['os_family']=="Debian" %} /etc/apache2/envvars: file.managed: diff --git a/apache/init.sls b/apache/init.sls index becb3d6..9731c5b 100644 --- a/apache/init.sls +++ b/apache/init.sls @@ -14,14 +14,6 @@ apache: - name: {{ apache.service }} - enable: True -{{ apache.vhostdir }}: - file.directory: - - makedirs: True - - require: - - pkg: apache - - watch_in: - - service: apache - # The following states are inert by default and can be used by other states to # trigger a restart or reload as needed. apache-reload: