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.

пре 10 година
пре 10 година
пре 10 година
пре 10 година
пре 10 година
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. {% from "nginx/map.jinja" import nginx as nginx_map with context %}
  2. {% set nginx = pillar.get('nginx', {}) -%}
  3. {% set home = nginx.get('home', '/var/www') -%}
  4. {% set conf_dir = nginx.get('conf_dir', '/etc/nginx') -%}
  5. {% set conf_template = nginx.get('conf_template', 'salt://nginx/templates/config.jinja') -%}
  6. {{ home }}:
  7. file:
  8. - directory
  9. - user: {{ nginx_map.default_user }}
  10. - group: {{ nginx_map.default_group }}
  11. - mode: 0755
  12. - makedirs: True
  13. - require:
  14. {%- if pillar.get('nginx', {}).get('install_from_source', false) %}
  15. - user: {{ nginx_map.default_user }}
  16. - group: {{ nginx_map.default_group }}
  17. {%- else %}
  18. - pkg: nginx
  19. {% endif %}
  20. /usr/share/nginx:
  21. file:
  22. - directory
  23. {% for filename in ('default', 'example_ssl') %}
  24. {{ conf_dir }}/conf.d/{{ filename }}.conf:
  25. file.absent
  26. {% endfor %}
  27. {{ conf_dir }}:
  28. file.directory:
  29. - user: root
  30. - group: root
  31. - makedirs: True
  32. {{ conf_dir }}/nginx.conf:
  33. file:
  34. - managed
  35. - template: jinja
  36. - user: root
  37. - group: root
  38. - mode: 644
  39. - source: {{ conf_template }}
  40. - require:
  41. - file: {{ conf_dir }}
  42. - context:
  43. default_user: {{ nginx_map.default_user }}
  44. default_group: {{ nginx_map.default_group }}
  45. {% if nginx.get('init_conf_dirs', True) %}
  46. {% for dir in ('sites-enabled', 'sites-available') %}
  47. {{ conf_dir }}/{{ dir }}:
  48. file.directory:
  49. - user: root
  50. - group: root
  51. {% endfor -%}
  52. {% endif %}