implement inline config

This commit is contained in:
histausse 2022-07-17 20:13:18 +02:00
parent 94e48cbdae
commit 4ea5f2c6be
Signed by: histausse
GPG key ID: 67486F107F62E9E9
2 changed files with 14 additions and 5 deletions

View file

@ -46,6 +46,8 @@ http_sites:
`location`: `location`:
templates: templates:
- `template` - `template`
config:
- `config`
... ...
``` ```
@ -53,7 +55,7 @@ http_sites:
`root_snippets` is a list of snippets/templates (To be determine) containing configurations for the http server. `root_snippets` is a list of snippets/templates (To be determine) containing configurations for the http server.
`locations` is a dictionnary of location block. `location` (the key of an item) is the location (eg, "/"), `template` is the jinja template defining the contant of the location block. Other variables can be added to the location block depending on the template used. `locations` is a dictionnary of location block. `location` (the key of an item) is the location (eg, "/"), `template` are the jinja templates defining the contant of the location block. Other variables can be added to the location block depending on the template used. `config` is a string added directly to the config of the location block.
Inside the templates, `server_name` is accessed with `{{ item.key }}`, en variables of the server block with `{{ item.value.varname }}`. Inside the templates, `server_name` is accessed with `{{ item.key }}`, en variables of the server block with `{{ item.value.varname }}`.

View file

@ -52,12 +52,19 @@ server {
{% for location in (item.value.locations | default({}) | dict2items) -%} {% for location in (item.value.locations | default({}) | dict2items) -%}
location {{ location.key }} { location {{ location.key }} {
{% filter indent(width=8) -%} {% filter indent(width=8) -%}
{% for template in (location.value.templates | default([])) -%} {%- for config in (location.value.config | default([])) -%}
{% include template -%} {{ config }}
{%- endfor %}
{%- endfor -%}
{%- for template in (location.value.templates | default([])) -%}
{% include template %}
{%- endfor -%}
{%- endfilter %} {%- endfilter %}
} }
{%- endfor %}
{% endfor %}
} }