Saltstack Official Nginx Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536
  1. # nginx.snippet
  2. #
  3. # Manages creation of snippets
  4. {%- set tplroot = tpldir.split('/')[0] %}
  5. {%- from tplroot ~ '/map.jinja' import nginx, sls_block with context %}
  6. {%- from tplroot ~ '/libtofs.jinja' import files_switch with context %}
  7. {#- _nginx is a lightened copy of nginx map intended to passed in templates #}
  8. {%- set _nginx = nginx.copy() %}
  9. {%- do _nginx.pop('snippets') if nginx.snippets is defined %}
  10. {%- do _nginx.pop('servers') if nginx.servers is defined %}
  11. nginx_snippets_dir:
  12. file.directory:
  13. {{ sls_block(nginx.servers.dir_opts) }}
  14. - name: {{ nginx.lookup.snippets_dir }}
  15. {% for snippet, config in nginx.snippets.items() %}
  16. nginx_snippet_{{ snippet }}:
  17. file.managed:
  18. - name: {{ nginx.lookup.snippets_dir ~ '/' ~ snippet }}
  19. - source: {{ files_switch([ snippet, 'server.conf' ],
  20. 'nginx_snippet_file_managed'
  21. )
  22. }}
  23. - template: jinja
  24. - context:
  25. config: {{ config|json() }}
  26. nginx: {{ _nginx|json() }}
  27. - require:
  28. - file: nginx_snippets_dir
  29. - require_in:
  30. - file: nginx_config
  31. - service: nginx_service
  32. {% endfor %}