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.

52 lines
1.2KB

  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. /usr/share/nginx:
  14. file:
  15. - directory
  16. {% for filename in ('default', 'example_ssl') %}
  17. {{ conf_dir }}/conf.d/{{ filename }}.conf:
  18. file.absent
  19. {% endfor %}
  20. {{ conf_dir }}:
  21. file.directory:
  22. - user: root
  23. - group: root
  24. - makedirs: True
  25. {{ conf_dir }}/nginx.conf:
  26. file:
  27. - managed
  28. - template: jinja
  29. - user: root
  30. - group: root
  31. - mode: 644
  32. - source: {{ conf_template }}
  33. - require:
  34. - file: {{ conf_dir }}
  35. - context:
  36. default_user: {{ nginx_map.default_user }}
  37. default_group: {{ nginx_map.default_group }}
  38. {% if nginx.get('init_conf_dirs', True) %}
  39. {% for dir in ('sites-enabled', 'sites-available') %}
  40. {{ conf_dir }}/{{ dir }}:
  41. file.directory:
  42. - user: root
  43. - group: root
  44. {% endfor -%}
  45. {% endif %}