Merge pull request #293 from SuperTux88/refactor-vhosts-template
refactor(vhosts): reduce empty lines in standard.tmpl and proxy.tmpl
This commit is contained in:
commit
c2c3b7c848
@ -2,7 +2,7 @@
|
|||||||
# This file is managed by Salt! Do not edit by hand!
|
# This file is managed by Salt! Do not edit by hand!
|
||||||
#
|
#
|
||||||
{# Define default values here so the template below can just focus on layout #}
|
{# Define default values here so the template below can just focus on layout #}
|
||||||
{% set sitename = site.get('ServerName', id) %}
|
{% set sitename = site.get('ServerName', id) -%}
|
||||||
{% set vals = {
|
{% set vals = {
|
||||||
'interfaces': site.get('interface', '*').split(),
|
'interfaces': site.get('interface', '*').split(),
|
||||||
'port': site.get('port', '80'),
|
'port': site.get('port', '80'),
|
||||||
@ -33,8 +33,9 @@
|
|||||||
'Allow': 'from all',
|
'Allow': 'from all',
|
||||||
'Require': 'all granted',
|
'Require': 'all granted',
|
||||||
},
|
},
|
||||||
} %}
|
} -%}
|
||||||
<VirtualHost {% for intf in vals.interfaces %} {{ intf }}:{{ vals.port }}{% endfor -%}>
|
|
||||||
|
<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 %}
|
||||||
{% if site.get('ServerAdmin') != False %}ServerAdmin {{ vals.ServerAdmin }}{% endif %}
|
{% if site.get('ServerAdmin') != False %}ServerAdmin {{ vals.ServerAdmin }}{% endif %}
|
||||||
@ -50,17 +51,17 @@
|
|||||||
SSLCertificateFile {{ site.SSLCertificateFile }}
|
SSLCertificateFile {{ site.SSLCertificateFile }}
|
||||||
{% if site.get('SSLCertificateKeyFile') %}SSLCertificateKeyFile {{ site.SSLCertificateKeyFile }}{% endif %}
|
{% if site.get('SSLCertificateKeyFile') %}SSLCertificateKeyFile {{ site.SSLCertificateKeyFile }}{% endif %}
|
||||||
{% if site.get('SSLCertificateChainFile') %}SSLCertificateChainFile {{ site.SSLCertificateChainFile }}{% endif %}
|
{% if site.get('SSLCertificateChainFile') %}SSLCertificateChainFile {{ site.SSLCertificateChainFile }}{% endif %}
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
{% if site.get('Rewrite') %}RewriteEngine on
|
{% if site.get('Rewrite') %}RewriteEngine on
|
||||||
{{ site.Rewrite }}
|
{{ site.Rewrite|indent(4) }}
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
{% if site.get('SSLProxyEngine') %}SSLProxyEngine {{ site.SSLProxyEngine }}{% endif %}
|
{% if site.get('SSLProxyEngine') %}SSLProxyEngine {{ site.SSLProxyEngine }}{% endif %}
|
||||||
ProxyRequests {{ vals.ProxyRequests }}
|
ProxyRequests {{ vals.ProxyRequests }}
|
||||||
ProxyPreserveHost {{ vals.ProxyPreserveHost }}
|
ProxyPreserveHost {{ vals.ProxyPreserveHost }}
|
||||||
{% if site.get('ProxyErrorOverride') %}ProxyErrorOverride {{ site.ProxyErrorOverride }} {% endif %}
|
{% if site.get('ProxyErrorOverride') %}ProxyErrorOverride {{ site.ProxyErrorOverride }} {% endif %}
|
||||||
{% if site.get('ProxyErrorDir') %}ProxyPass /{{ site.ProxyErrorDir }}/ ! {% endif %}
|
{% if site.get('ProxyErrorDir') %}ProxyPass /{{ site.ProxyErrorDir }}/ ! {% endif %}
|
||||||
{% for proxy, proxyargs in vals.ProxyRoute|dictsort|reverse %}
|
{%- for proxy, proxyargs in vals.ProxyRoute|dictsort|reverse %}
|
||||||
{% set proxyvals = {
|
{%- set proxyvals = {
|
||||||
'ProxyPassSource': proxyargs.get('ProxyPassSource', '/'),
|
'ProxyPassSource': proxyargs.get('ProxyPassSource', '/'),
|
||||||
'ProxyPassTarget': proxyargs.get('ProxyPassTarget', 'https://{0}'.format(sitename)),
|
'ProxyPassTarget': proxyargs.get('ProxyPassTarget', 'https://{0}'.format(sitename)),
|
||||||
'ProxyPassTargetOptions': proxyargs.get('ProxyPassTargetOptions', ''),
|
'ProxyPassTargetOptions': proxyargs.get('ProxyPassTargetOptions', ''),
|
||||||
@ -72,59 +73,59 @@
|
|||||||
ProxyPassReverse {{ proxyvals.ProxyPassReverseSource }} {{ proxyvals.ProxyPassReverseTarget }}
|
ProxyPassReverse {{ proxyvals.ProxyPassReverseSource }} {{ proxyvals.ProxyPassReverseTarget }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% for path, loc in site.get('Location', {}).items() %}
|
{%- for path, loc in site.get('Location', {}).items() %}
|
||||||
{% set lvals = {
|
{%- set lvals = {
|
||||||
'Order': loc.get('Order', vals.Location.Order),
|
'Order': loc.get('Order', vals.Location.Order),
|
||||||
'Allow': loc.get('Allow', vals.Location.Allow),
|
'Allow': loc.get('Allow', vals.Location.Allow),
|
||||||
'Require': loc.get('Require', vals.Location.Require),
|
'Require': loc.get('Require', vals.Location.Require),
|
||||||
'Dav': loc.get('Dav', False),
|
'Dav': loc.get('Dav', False),
|
||||||
} %}
|
} %}
|
||||||
<Location "{{ path }}">
|
<Location "{{ path }}">
|
||||||
{% if apache.version == '2.4' %}
|
{%- if apache.version == '2.4' %}
|
||||||
{% if lvals.get('Require') != False %}Require {{ lvals.Require }}{% endif %}
|
{% if lvals.get('Require') != False %}Require {{ lvals.Require }}{% endif %}
|
||||||
{% else %}
|
{%- else %}
|
||||||
{% if lvals.get('Order') != False %}Order {{ lvals.Order }}{% endif %}
|
{% if lvals.get('Order') != False %}Order {{ lvals.Order }}{% endif %}
|
||||||
{% if lvals.get('Allow') != False %}Allow {{ lvals.Allow }}{% endif %}
|
{% if lvals.get('Allow') != False %}Allow {{ lvals.Allow }}{% endif %}
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
{% if loc.get('Formula_Append') %} {{ loc.Formula_Append|indent(8) }} {% endif %}
|
{% if loc.get('Formula_Append') %} {{ loc.Formula_Append|indent(8) }} {% endif %}
|
||||||
</Location>
|
</Location>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for regpath, locmat in site.get('LocationMatch', {}).items() %}
|
{%- for regpath, locmat in site.get('LocationMatch', {}).items() %}
|
||||||
{% set lmvals = {
|
{%- set lmvals = {
|
||||||
'Order': locmat.get('Order', vals.LocationMatch.Order),
|
'Order': locmat.get('Order', vals.LocationMatch.Order),
|
||||||
'Allow': locmat.get('Allow', vals.LocationMatch.Allow),
|
'Allow': locmat.get('Allow', vals.LocationMatch.Allow),
|
||||||
'Require': locmat.get('Require', vals.LocationMatch.Require),
|
'Require': locmat.get('Require', vals.LocationMatch.Require),
|
||||||
'Dav': locmat.get('Dav', False),
|
'Dav': locmat.get('Dav', False),
|
||||||
} %}
|
} %}
|
||||||
<LocationMatch "{{ regpath }}">
|
<LocationMatch "{{ regpath }}">
|
||||||
{% if apache.version == '2.4' %}
|
{%- if apache.version == '2.4' %}
|
||||||
{% if lmvals.get('Require') != False %}Require {{ lmvals.Require }}{% endif %}
|
{% if lmvals.get('Require') != False %}Require {{ lmvals.Require }}{% endif %}
|
||||||
{% else %}
|
{%- else %}
|
||||||
{% if lmvals.get('Order') != False %}Order {{ lmvals.Order }}{% endif %}
|
{% if lmvals.get('Order') != False %}Order {{ lmvals.Order }}{% endif %}
|
||||||
{% if lmvals.get('Allow') != False %}Allow {{ lmvals.Allow }}{% endif %}
|
{% if lmvals.get('Allow') != False %}Allow {{ lmvals.Allow }}{% endif %}
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
{% if locmat.get('Formula_Append') %} {{ locmat.Formula_Append|indent(8) }} {% endif %}
|
{% if locmat.get('Formula_Append') %} {{ locmat.Formula_Append|indent(8) }} {% endif %}
|
||||||
</LocationMatch>
|
</LocationMatch>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for proxypath, prox in site.get('Proxy_control', {}).items() %}
|
{%- for proxypath, prox in site.get('Proxy_control', {}).items() %}
|
||||||
{% set proxvals = {
|
{%- set proxvals = {
|
||||||
'AllowAll': prox.get('AllowAll', vals.AllowAll),
|
'AllowAll': prox.get('AllowAll', vals.AllowAll),
|
||||||
'AllowCountry': prox.get('AllowCountry', vals.AllowCountry),
|
'AllowCountry': prox.get('AllowCountry', vals.AllowCountry),
|
||||||
'AllowIP': prox.get('AllowIP', vals.AllowIP),
|
'AllowIP': prox.get('AllowIP', vals.AllowIP),
|
||||||
} %}
|
} %}
|
||||||
<Proxy "{{ proxypath }}">
|
<Proxy "{{ proxypath }}">
|
||||||
{% if proxvals.get('AllowAll') != False %}
|
{%- if proxvals.get('AllowAll') != False %}
|
||||||
Require all granted
|
Require all granted
|
||||||
{% else %}
|
{%- else %}
|
||||||
{% if proxvals.get('AllowCountry') != False %}{% set country_list = proxvals.get('AllowCountry', {}) %}GeoIPEnable On
|
{% if proxvals.get('AllowCountry') != False %}{% set country_list = proxvals.get('AllowCountry', {}) %}GeoIPEnable On
|
||||||
{% for every_country in country_list %}SetEnvIf GEOIP_COUNTRY_CODE {{ every_country }} AllowCountry
|
{% for every_country in country_list %}SetEnvIf GEOIP_COUNTRY_CODE {{ every_country }} AllowCountry
|
||||||
{% endfor %}Require env AllowCountry {% endif %}
|
{% endfor %}Require env AllowCountry {% endif %}
|
||||||
{% if proxvals.get('AllowIP') is defined %} {% set ip_list = proxvals.get('AllowIP', {}) %}
|
{% if proxvals.get('AllowIP') is defined %}{% set ip_list = proxvals.get('AllowIP', {}) %}
|
||||||
Require ip {% for every_ip in ip_list %}{{ every_ip }} {% endfor %} {% endif %}
|
Require ip {% for every_ip in ip_list %}{{ every_ip }} {% endfor %} {% endif %}
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
</Proxy>
|
</Proxy>
|
||||||
{% endfor %}
|
{%- endfor %}
|
||||||
{% if site.get('Formula_Append') %}
|
{%- if site.get('Formula_Append') %}
|
||||||
{{ site.Formula_Append|indent(4) }}
|
{{ site.Formula_Append|indent(4) }}
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
},
|
},
|
||||||
} -%}
|
} -%}
|
||||||
|
|
||||||
<VirtualHost {% for intf in vals.interfaces %} {{ intf }}:{{ vals.port }}{% endfor -%}>
|
<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 %}
|
||||||
|
|
||||||
@ -68,22 +68,22 @@
|
|||||||
SSLCertificateFile {{ site.SSLCertificateFile }}
|
SSLCertificateFile {{ site.SSLCertificateFile }}
|
||||||
{% if site.get('SSLCertificateKeyFile') %}SSLCertificateKeyFile {{ site.SSLCertificateKeyFile }}{% endif %}
|
{% if site.get('SSLCertificateKeyFile') %}SSLCertificateKeyFile {{ site.SSLCertificateKeyFile }}{% endif %}
|
||||||
{% if site.get('SSLCertificateChainFile') %}SSLCertificateChainFile {{ site.SSLCertificateChainFile }}{% endif %}
|
{% if site.get('SSLCertificateChainFile') %}SSLCertificateChainFile {{ site.SSLCertificateChainFile }}{% endif %}
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
|
|
||||||
{% if site.get('Rewrite') %}RewriteEngine on
|
{% if site.get('Rewrite') %}RewriteEngine on
|
||||||
{{ site.Rewrite }}
|
{{ site.Rewrite|indent(4) }}
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
|
|
||||||
{% for loc, path in site.get('Alias', {}).items() %}
|
{%- for loc, path in site.get('Alias', {}).items() %}
|
||||||
Alias {{ loc }} {{ path }}
|
Alias {{ loc }} {{ path }}
|
||||||
{% endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
{% for loc, path in site.get('ScriptAlias', {}).items() %}
|
{%- for loc, path in site.get('ScriptAlias', {}).items() %}
|
||||||
ScriptAlias {{ loc }} {{ path }}
|
ScriptAlias {{ loc }} {{ path }}
|
||||||
{% endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
{% for path, dir in site.get('Directory', {}).items() -%}
|
{%- for path, dir in site.get('Directory', {}).items() %}
|
||||||
{% set dvals = {
|
{%- set dvals = {
|
||||||
'Options': dir.get('Options', vals.Directory.Options),
|
'Options': dir.get('Options', vals.Directory.Options),
|
||||||
'Order': dir.get('Order', vals.Directory.Order),
|
'Order': dir.get('Order', vals.Directory.Order),
|
||||||
'Allow': dir.get('Allow', vals.Directory.Allow),
|
'Allow': dir.get('Allow', vals.Directory.Allow),
|
||||||
@ -92,28 +92,27 @@
|
|||||||
'Dav': dir.get('Dav', False),
|
'Dav': dir.get('Dav', False),
|
||||||
} %}
|
} %}
|
||||||
|
|
||||||
{% if path == 'default' %}{% set path = vals.Directory_default %}{% endif %}
|
{%- if path == 'default' %}{% set path = vals.Directory_default %}{% endif %}
|
||||||
|
|
||||||
<Directory "{{ path }}">
|
<Directory "{{ path }}">
|
||||||
{% if dvals.get('Options') != False %}Options {{ dvals.Options }}{% endif %}
|
{% if dvals.get('Options') != False %}Options {{ dvals.Options }}{% endif %}
|
||||||
{% if map.version == '2.4' %}
|
{%- if map.version == '2.4' %}
|
||||||
{% if dvals.get('Require') != False %}Require {{ dvals.Require }}{% endif %}
|
{% if dvals.get('Require') != False %}Require {{ dvals.Require }}{% endif %}
|
||||||
{% else %}
|
{%- else %}
|
||||||
{% if dvals.get('Order') != False %}Order {{ dvals.Order }}{% endif %}
|
{% if dvals.get('Order') != False %}Order {{ dvals.Order }}{% endif %}
|
||||||
|
|
||||||
{% if dvals.get('Allow') != False %}Allow {{ dvals.Allow }}{% endif %}
|
{% if dvals.get('Allow') != False %}Allow {{ dvals.Allow }}{% endif %}
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
{% if dvals.get('AllowOverride') != False %}AllowOverride {{ dvals.AllowOverride }}{% endif %}
|
{% if dvals.get('AllowOverride') != False %}AllowOverride {{ dvals.AllowOverride }}{% endif %}
|
||||||
{% if dvals.get('Dav') != False %}Dav On{% endif %}
|
{% if dvals.get('Dav') != False %}Dav On{% endif %}
|
||||||
|
|
||||||
{% if dir.get('Formula_Append') %}
|
{%- if dir.get('Formula_Append') %}
|
||||||
{{ dir.Formula_Append|indent(8) }}
|
{{ dir.Formula_Append|indent(8) }}
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
</Directory>
|
</Directory>
|
||||||
{% endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
{% for path, loc in site.get('Location', {}).items() %}
|
{%- for path, loc in site.get('Location', {}).items() %}
|
||||||
{% set lvals = {
|
{%- set lvals = {
|
||||||
'Order': loc.get('Order', vals.Location.Order),
|
'Order': loc.get('Order', vals.Location.Order),
|
||||||
'Allow': loc.get('Allow', vals.Location.Allow),
|
'Allow': loc.get('Allow', vals.Location.Allow),
|
||||||
'Require': loc.get('Require', vals.Location.Require),
|
'Require': loc.get('Require', vals.Location.Require),
|
||||||
@ -121,21 +120,21 @@
|
|||||||
} %}
|
} %}
|
||||||
|
|
||||||
<Location "{{ path }}">
|
<Location "{{ path }}">
|
||||||
{% if map.version == '2.4' %}
|
{%- if map.version == '2.4' %}
|
||||||
{% if lvals.get('Require') != False %}Require {{ lvals.Require }}{% endif %}
|
{% if lvals.get('Require') != False %}Require {{ lvals.Require }}{% endif %}
|
||||||
{% else %}
|
{%- else %}
|
||||||
{% if lvals.get('Order') != False %}Order {{ lvals.Order }}{% endif %}
|
{% if lvals.get('Order') != False %}Order {{ lvals.Order }}{% endif %}
|
||||||
{% if lvals.get('Allow') != False %}Allow {{ lvals.Allow }}{% endif %}
|
{% if lvals.get('Allow') != False %}Allow {{ lvals.Allow }}{% endif %}
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
{% if lvals.get('Dav') != False %}Dav On{% endif %}
|
{% if lvals.get('Dav') != False %}Dav On{% endif %}
|
||||||
|
|
||||||
{% if loc.get('Formula_Append') %}
|
{%- if loc.get('Formula_Append') %}
|
||||||
{{ loc.Formula_Append|indent(8) }}
|
{{ loc.Formula_Append|indent(8) }}
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
</Location>
|
</Location>
|
||||||
{% endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
{% if site.get('Formula_Append') %}
|
{%- if site.get('Formula_Append') %}
|
||||||
{{ site.Formula_Append|indent(4) }}
|
{{ site.Formula_Append|indent(4) }}
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
|
Loading…
Reference in New Issue
Block a user