This is done by split the interface pillar value instead of using a proper list so it behaves exactly the same as before for simple 1 interface cases (no need to refactor one's pillar files). The resulting is something like: Listen 1.2.3.4:80 Listen [2001:abc:def:100::3]:80 <VirtualHost 1.2.3.4:80 [2001:abc:def:100::3]:80> ...master
example.com: # must be unique; used as an ID declaration in Salt; also passed to the template context as {{ id }} | example.com: # must be unique; used as an ID declaration in Salt; also passed to the template context as {{ id }} | ||||
template_file: salt://apache/vhosts/standard.tmpl | template_file: salt://apache/vhosts/standard.tmpl | ||||
When using the provided templates, one can use a space separated list | |||||
of interfaces to bind to. For example, to bind both IPv4 and IPv6: | |||||
.. code:: yaml | |||||
apache: | |||||
sites: | |||||
example.com: | |||||
interface: '1.2.3.4 [2001:abc:def:100::3]' | |||||
``apache.manage_security`` | ``apache.manage_security`` | ||||
-------------------------- | -------------------------- | ||||
{% set sitename = site.get('ServerName', id) %} | {% set sitename = site.get('ServerName', id) %} | ||||
{% set vals = { | {% set vals = { | ||||
'interface': site.get('interface', '*'), | |||||
'interfaces': site.get('interface', '*').split(), | |||||
'port': site.get('port', '80'), | 'port': site.get('port', '80'), | ||||
'ServerName': sitename, | 'ServerName': sitename, | ||||
'ProxyRoute': site.get('ProxyRoute', {}), | 'ProxyRoute': site.get('ProxyRoute', {}), | ||||
} %} | } %} | ||||
Listen {{ vals.interface }}:{{ vals.port }} | |||||
{% for intf in vals.interfaces -%} | |||||
Listen {{ intf }}:{{ vals.port }} | |||||
{% endfor %} | |||||
<VirtualHost {{ vals.interface }}:{{ vals.port }}> | |||||
<VirtualHost {%- for intf in vals.interfaces %} {{intf}}:{{ vals.port }}{% endfor -%}> | |||||
ServerName {{ vals.ServerName }} | ServerName {{ vals.ServerName }} | ||||
{% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %} | {% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %} | ||||
{% set sitename = site.get('ServerName', id) %} | {% set sitename = site.get('ServerName', id) %} | ||||
{% set vals = { | {% set vals = { | ||||
'interface': site.get('interface', '*'), | |||||
'interfaces': site.get('interface', '*').split(), | |||||
'port': site.get('port', '80'), | 'port': site.get('port', '80'), | ||||
'ServerName': sitename, | 'ServerName': sitename, | ||||
} %} | } %} | ||||
Listen {{ vals.interface }}:{{ vals.port }} | |||||
{% for intf in vals.interfaces -%} | |||||
Listen {{ intf }}:{{ vals.port }} | |||||
{% endfor %} | |||||
<VirtualHost {{ vals.interface }}:{{ vals.port }}> | |||||
<VirtualHost {%- for intf in vals.interfaces %} {{intf}}:{{ vals.port }}{% endfor -%}> | |||||
ServerName {{ vals.ServerName }} | ServerName {{ vals.ServerName }} | ||||
{% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %} | {% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %} | ||||
{% set sitename = site.get('ServerName', id) %} | {% set sitename = site.get('ServerName', id) %} | ||||
{% set vals = { | {% set vals = { | ||||
'interface': site.get('interface', '*'), | |||||
'interfaces': site.get('interface', '*').split(), | |||||
'port': site.get('port', '80'), | 'port': site.get('port', '80'), | ||||
'ServerName': sitename, | 'ServerName': sitename, | ||||
}, | }, | ||||
} %} | } %} | ||||
Listen {{ vals.interface }}:{{ vals.port }} | |||||
{% for intf in vals.interfaces -%} | |||||
Listen {{ intf }}:{{ vals.port }} | |||||
{% endfor %} | |||||
<VirtualHost {{ vals.interface }}:{{ vals.port }}> | |||||
<VirtualHost {%- for intf in vals.interfaces %} {{intf}}:{{ vals.port }}{% endfor -%}> | |||||
ServerName {{ vals.ServerName }} | ServerName {{ vals.ServerName }} | ||||
{% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %} | {% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %} | ||||