Browse Source

feat(context): pass `nginx` to snippets and server_config contexts

tags/v2.5.0
sticky-note 4 years ago
parent
commit
8641f0d79a
2 changed files with 11 additions and 0 deletions
  1. +5
    -0
      nginx/servers_config.sls
  2. +6
    -0
      nginx/snippets.sls

+ 5
- 0
nginx/servers_config.sls View File

{%- from tplroot ~ '/libtofs.jinja' import files_switch with context %} {%- from tplroot ~ '/libtofs.jinja' import files_switch with context %}


{% set server_states = [] %} {% 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. # Simple path concatenation.
# Needs work to make this function on windows. # Needs work to make this function on windows.
{% if 'source_path' not in settings.config %} {% if 'source_path' not in settings.config %}
- context: - context:
config: {{ settings.config|json(sort_keys=False) }} config: {{ settings.config|json(sort_keys=False) }}
nginx: {{ _nginx|json() }}
{% endif %} {% endif %}
{% if 'overwrite' in settings and settings.overwrite == False %} {% if 'overwrite' in settings and settings.overwrite == False %}
- unless: - unless:

+ 6
- 0
nginx/snippets.sls View File

{%- from tplroot ~ '/map.jinja' import nginx, sls_block with context %} {%- from tplroot ~ '/map.jinja' import nginx, sls_block with context %}
{%- from tplroot ~ '/libtofs.jinja' import files_switch 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: nginx_snippets_dir:
file.directory: file.directory:
{{ sls_block(nginx.servers.dir_opts) }} {{ sls_block(nginx.servers.dir_opts) }}
- template: jinja - template: jinja
- context: - context:
config: {{ config|json() }} config: {{ config|json() }}
nginx: {{ _nginx|json() }}
{% endfor %} {% endfor %}

Loading…
Cancel
Save