Saltstack Official Nginx Formula
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

37 lines
1.1KB

  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') %}
  10. {%- do _nginx.pop('servers') %}
  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 %}