Skip to content

Commit 8641f0d

Browse files
author
sticky-note
committed
feat(context): pass nginx to snippets and server_config contexts
1 parent 33d9ab7 commit 8641f0d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

nginx/servers_config.sls

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
{%- from tplroot ~ '/libtofs.jinja' import files_switch with context %}
99
1010
{% set server_states = [] %}
11+
{#- _nginx is a lightened copy of nginx map intended to passed in templates #}
12+
{%- set _nginx = nginx.copy() %}
13+
{%- do _nginx.pop('snippets') %}
14+
{%- do _nginx.pop('servers') %}
1115
1216
# Simple path concatenation.
1317
# Needs work to make this function on windows.
@@ -126,6 +130,7 @@ nginx_server_available_dir:
126130
{% if 'source_path' not in settings.config %}
127131
- context:
128132
config: {{ settings.config|json(sort_keys=False) }}
133+
nginx: {{ _nginx|json() }}
129134
{% endif %}
130135
{% if 'overwrite' in settings and settings.overwrite == False %}
131136
- unless:

nginx/snippets.sls

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
{%- from tplroot ~ '/map.jinja' import nginx, sls_block with context %}
77
{%- from tplroot ~ '/libtofs.jinja' import files_switch with context %}
88
9+
{#- _nginx is a lightened copy of nginx map intended to passed in templates #}
10+
{%- set _nginx = nginx.copy() %}
11+
{%- do _nginx.pop('snippets') %}
12+
{%- do _nginx.pop('servers') %}
13+
914
nginx_snippets_dir:
1015
file.directory:
1116
{{ sls_block(nginx.servers.dir_opts) }}
@@ -22,4 +27,5 @@ nginx_snippet_{{ snippet }}:
2227
- template: jinja
2328
- context:
2429
config: {{ config|json() }}
30+
nginx: {{ _nginx|json() }}
2531
{% endfor %}

0 commit comments

Comments
 (0)