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.

74 lines
1.5KB

  1. {% set use_upstart = pillar.get('nginx', {}).get('use_upstart', true) %}
  2. {% if use_upstart %}
  3. nginx-old-init:
  4. file:
  5. - rename
  6. - name: /usr/share/nginx/init.d
  7. - source: /etc/init.d/nginx
  8. - require_in:
  9. - file: nginx
  10. cmd:
  11. - wait
  12. - name: dpkg-divert --divert /usr/share/nginx/init.d --add /etc/init.d/nginx
  13. - require:
  14. - module: nginx-old-init
  15. - watch:
  16. - file: nginx-old-init
  17. - require_in:
  18. - file: nginx
  19. module:
  20. - wait
  21. - name: cmd.run
  22. - cmd: kill `cat /var/run/nginx.pid`
  23. - watch:
  24. - file: nginx-old-init
  25. - require_in:
  26. - file: nginx
  27. nginx-old-init-disable:
  28. cmd:
  29. - wait
  30. - name: update-rc.d -f nginx remove
  31. - require:
  32. - module: nginx-old-init
  33. - watch:
  34. - file: nginx-old-init
  35. {% endif %}
  36. nginx:
  37. pkg.installed:
  38. - name: nginx
  39. {% if use_upstart %}
  40. file:
  41. - managed
  42. - name: /etc/init/nginx.conf
  43. - template: jinja
  44. - user: root
  45. - group: root
  46. - mode: 440
  47. - source: salt://nginx/templates/upstart.jinja
  48. - require:
  49. - pkg: nginx
  50. - file: nginx-old-init
  51. - module: nginx-old-init
  52. {% endif %}
  53. service:
  54. - running
  55. - enable: True
  56. - restart: True
  57. - watch:
  58. {% if use_upstart %}
  59. - file: nginx
  60. {% endif %}
  61. - file: /etc/nginx/nginx.conf
  62. - file: /etc/nginx/conf.d/default.conf
  63. - file: /etc/nginx/conf.d/example_ssl.conf
  64. - pkg: nginx
  65. # Create 'service' symlink for tab completion.
  66. {% if use_upstart %}
  67. /etc/init.d/nginx:
  68. file.symlink:
  69. - target: /lib/init/upstart-job
  70. {% endif %}