Skip to content

Commit

Permalink
feat(context): pass nginx to snippets and server_config contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
sticky-note committed Dec 17, 2020
1 parent 33d9ab7 commit 8641f0d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nginx/servers_config.sls
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
{%- from tplroot ~ '/libtofs.jinja' import files_switch with context %}
{% set server_states = [] %}
{#- _nginx is a lightened copy of nginx map intended to passed in templates #}
{%- set _nginx = nginx.copy() %}
{%- do _nginx.pop('snippets') %}
{%- do _nginx.pop('servers') %}
# Simple path concatenation.
# Needs work to make this function on windows.
Expand Down Expand Up @@ -126,6 +130,7 @@ nginx_server_available_dir:
{% if 'source_path' not in settings.config %}
- context:
config: {{ settings.config|json(sort_keys=False) }}
nginx: {{ _nginx|json() }}
{% endif %}
{% if 'overwrite' in settings and settings.overwrite == False %}
- unless:
Expand Down
6 changes: 6 additions & 0 deletions nginx/snippets.sls
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
{%- from tplroot ~ '/map.jinja' import nginx, sls_block with context %}
{%- from tplroot ~ '/libtofs.jinja' import files_switch with context %}
{#- _nginx is a lightened copy of nginx map intended to passed in templates #}
{%- set _nginx = nginx.copy() %}
{%- do _nginx.pop('snippets') %}
{%- do _nginx.pop('servers') %}
nginx_snippets_dir:
file.directory:
{{ sls_block(nginx.servers.dir_opts) }}
Expand All @@ -22,4 +27,5 @@ nginx_snippet_{{ snippet }}:
- template: jinja
- context:
config: {{ config|json() }}
nginx: {{ _nginx|json() }}
{% endfor %}

0 comments on commit 8641f0d

Please sign in to comment.