4fa9d57d2b
In 4d04d95b02
(#113)
apache/vhosts/standard.sls has been modified by @genuss to include
apache.config on the basis that apache.config was now able to retrieve the
interfaces/ports from pillar data in apache:sites.
I use apache:sites to register virtual hosts with non-standard
"template_file" (they contain the desired configuration directly)
and the "interface/port" keys are thus not meaningful.
apache:
sites:
example.com:
template_file: salt://vm/example/apache-vhost.conf
DocumentRoot: False
The generated ports.conf ends up containing only "*:80" while
my virtual host configuration files need ports 80 and 443. The
situation was perfectly fine up to now because the default configuration
file handles both of those ports if you have mod_ssl installed.
People who want to use apache.config should just explicitly include
that state, we should not force its usage to all apache.vhosts.standard
users.
54 lines
1.5 KiB
Plaintext
54 lines
1.5 KiB
Plaintext
{% from "apache/map.jinja" import apache with context %}
|
|
|
|
include:
|
|
- apache
|
|
|
|
{% for id, site in salt['pillar.get']('apache:sites', {}).items() %}
|
|
{% set documentroot = site.get('DocumentRoot', '{0}/{1}'.format(apache.wwwdir, id)) %}
|
|
|
|
{{ id }}:
|
|
file:
|
|
- managed
|
|
- name: {{ apache.vhostdir }}/{{ id }}{{ apache.confext }}
|
|
- 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
|
|
|
|
{% if site.get('DocumentRoot') != False %}
|
|
{{ id }}-documentroot:
|
|
file.directory:
|
|
- unless: test -d {{ documentroot }}
|
|
- name: {{ documentroot }}
|
|
- makedirs: True
|
|
- allow_symlink: True
|
|
{% endif %}
|
|
|
|
{% if grains.os_family == 'Debian' %}
|
|
{% if site.get('enabled', True) %}
|
|
a2ensite {{ id }}{{ apache.confext }}:
|
|
cmd.run:
|
|
- unless: test -f /etc/apache2/sites-enabled/{{ id }}{{ apache.confext }}
|
|
- require:
|
|
- file: /etc/apache2/sites-available/{{ id }}{{ apache.confext }}
|
|
- watch_in:
|
|
- module: apache-reload
|
|
{% 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
|
|
{% endif %}
|
|
{% endif %}
|
|
|
|
{% endfor %}
|