Finishes vhost config template
This commit is contained in:
parent
81de880fe0
commit
825bd7950e
@ -0,0 +1,29 @@
|
||||
{% set ind_increment = 4 %}
|
||||
{%- macro vhost_config(values, key='', ind=0, lb='\n', delim=';', operator=' ') -%}
|
||||
{%- for value in values -%}
|
||||
{%- if value is number or value is string -%}
|
||||
{{ lb }}{{ key|indent(ind, True) }}{{ operator }}{{ value }}{{ delim }}
|
||||
{%- elif value is mapping -%}
|
||||
{%- for k, v in value.items() -%}
|
||||
{%- if v is number or v is string -%}
|
||||
{{ vhost_config([v], k, ind) }}
|
||||
{%- elif v|length() > 0 and (v[0] is number or v[0] is string) -%}
|
||||
{{ lb }}{{ k|indent(ind,True) }}{{ vhost_config(v,'', 0, '', '')}}{{ delim }}
|
||||
{%- else %}
|
||||
{{ k|indent(ind, True) }} {{ '{' }}
|
||||
{{- vhost_config(v, '', ind + ind_increment) }}
|
||||
{{ '}'|indent(ind, True) }}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- elif value is iterable -%}
|
||||
{{ vhost_config(value, ind + ind_increment, delim, operator) }}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
# Nginx vhost configuration
|
||||
#
|
||||
# **** DO NOT EDIT THIS FILE ****
|
||||
#
|
||||
# This file is managed by Salt.
|
||||
{{ vhost_config(config) }}
|
@ -68,8 +68,7 @@
|
||||
'dir_opts': {
|
||||
'makedirs': True,
|
||||
},
|
||||
'managed': {}
|
||||
},
|
||||
'managed': {},
|
||||
},
|
||||
}, merge=True) %}
|
||||
|
||||
|
@ -92,7 +92,7 @@ nginx_vhost_available_dir:
|
||||
- source: salt://nginx/ng/files/vhost.conf
|
||||
- template: jinja
|
||||
- context:
|
||||
config: settings.config
|
||||
config: {{ settings.config }}
|
||||
{% do vhost_states.append(conf_state_id) %}
|
||||
{% endif %}
|
||||
|
||||
|
@ -13,6 +13,7 @@ nginx:
|
||||
# ========
|
||||
|
||||
nginx:
|
||||
ng:
|
||||
# These are usually set by grains in map.jinja
|
||||
lookup:
|
||||
package: nginx-custom
|
||||
@ -64,4 +65,32 @@ nginx:
|
||||
dir: /tmp # an alternate directory (not sites-available) where this vhost may be found
|
||||
disabled_name: mysite.aint_on # an alternative disabled name to be use when not symlinking
|
||||
enabled: True
|
||||
config: [] # May be a list or None, if None, no vhost file will be managed/templated
|
||||
|
||||
# May be a list of config options or None, if None, no vhost file will be managed/templated
|
||||
# Take server directives as lists of dictionaries. If the dictionary value is another list of
|
||||
# dictionaries a block {} will be started with the dictionary key name
|
||||
config:
|
||||
- server:
|
||||
- server_name: localhost
|
||||
- listen:
|
||||
- 80
|
||||
- default_server
|
||||
- index:
|
||||
- index.html
|
||||
- index.htm
|
||||
- location ~ .htm:
|
||||
- try_files:
|
||||
- $uri
|
||||
- $uri/ =404
|
||||
- test: something else
|
||||
|
||||
# The above outputs:
|
||||
# server {
|
||||
# server_name localhost;
|
||||
# listen 80 default_server;
|
||||
# index index.html index.htm;
|
||||
# location ~ .htm {
|
||||
# try_files $uri $uri/ =404;
|
||||
# test something else;
|
||||
# }
|
||||
# }
|
||||
|
Loading…
Reference in New Issue
Block a user