nginx-formula/nginx/ng/files/server.conf
Heinz Wiesinger 1541a59c83 Fix multiple values for the same key (include/listen) in server config file.
With this one can now also write

 - include:
   - file1
   - file2

Rather than only

 - include: file1
 - include: file2
2019-02-19 09:26:15 +01:00

30 lines
1.0 KiB
Plaintext

{% set ind_increment = 4 %}
{%- macro server_config(values, key='', ind=0, lb='\n', delim=';', operator=' ') -%}
{%- for value in values -%}
{%- if value is number or value is string -%}
{{ key|indent(ind, True) }}{{ operator }}{{ value }}{{ delim }}{{ lb }}
{%- elif value is mapping -%}
{%- for k, v in value.items() -%}
{%- if v is number or v is string -%}
{{ server_config([v], k, ind) }}
{%- elif v|length() > 0 and (v[0] is number or v[0] is string) -%}
{{ server_config(v, k, ind) }}
{%- else -%}
{{ lb }}{{ k|indent(ind, True) }} {{ '{' }}
{{ server_config(v, '', ind + ind_increment) -}}
{{ '}'|indent(ind, True) }}{{ lb }}
{%- endif -%}
{%- endfor -%}
{%- elif value is iterable -%}
{{ server_config(value, ind + ind_increment, delim, operator) }}
{%- endif -%}
{%- endfor -%}
{%- endmacro -%}
# Nginx server configuration
#
# **** DO NOT EDIT THIS FILE ****
#
# This file is managed by Salt.
{{ server_config(config) }}