diff --git a/apache/config.sls b/apache/config.sls index 4691f8e..6a29683 100644 --- a/apache/config.sls +++ b/apache/config.sls @@ -17,6 +17,7 @@ include: {{ apache.vhostdir }}: file.directory: + - makedirs: True - require: - pkg: apache - watch_in: diff --git a/apache/init.sls b/apache/init.sls index c3e170e..9731c5b 100644 --- a/apache/init.sls +++ b/apache/init.sls @@ -14,10 +14,6 @@ apache: - name: {{ apache.service }} - enable: True -{{ apache.vhostdir }}: - file.directory: - - makedirs: True - # The following states are inert by default and can be used by other states to # trigger a restart or reload as needed. apache-reload: 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