Saltstack Official Nginx Formula
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

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') 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 %}