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.

95 lines
2.2KB

  1. {% from "nginx/map.jinja" import nginx with context %}
  2. {% set use_upstart = pillar.get('nginx', {}).get('use_upstart', true) %}
  3. {% if use_upstart %}
  4. nginx-old-init:
  5. file:
  6. - rename
  7. - name: /usr/share/nginx/init.d
  8. - source: /etc/init.d/nginx
  9. - require_in:
  10. - file: nginx
  11. cmd:
  12. - wait
  13. - name: dpkg-divert --divert /usr/share/nginx/init.d --add /etc/init.d/nginx
  14. - require:
  15. - module: nginx-old-init
  16. - watch:
  17. - file: nginx-old-init
  18. - require_in:
  19. - file: nginx
  20. module:
  21. - wait
  22. - name: cmd.run
  23. - cmd: kill `cat /var/run/nginx.pid`
  24. - watch:
  25. - file: nginx-old-init
  26. - require_in:
  27. - file: nginx
  28. nginx-old-init-disable:
  29. cmd:
  30. - wait
  31. - name: update-rc.d -f nginx remove
  32. - require:
  33. - module: nginx-old-init
  34. - watch:
  35. - file: nginx-old-init
  36. {% endif %}
  37. {% if salt['grains.get']('os_family') == 'Debian' %}
  38. nginx-ppa-repo:
  39. pkgrepo:
  40. {%- if nginx.install_from_ppa %}
  41. - managed
  42. {%- else %}
  43. - absent
  44. {%- endif %}
  45. - humanname: nginx-ppa-{{ grains['oscodename'] }}
  46. - name: deb http://ppa.launchpad.net/nginx/stable/ubuntu {{ grains['oscodename'] }} main
  47. - file: /etc/apt/sources.list.d/nginx-stable-{{ grains['oscodename'] }}.list
  48. - dist: {{ grains['oscodename'] }}
  49. - keyid: C300EE8C
  50. - keyserver: keyserver.ubuntu.com
  51. - require_in:
  52. - pkg: nginx
  53. - watch_in:
  54. - pkg: nginx
  55. {% endif %}
  56. nginx:
  57. pkg.installed:
  58. - name: {{ nginx.package }}
  59. {% if use_upstart %}
  60. file:
  61. - managed
  62. - name: /etc/init/nginx.conf
  63. - template: jinja
  64. - user: root
  65. - group: root
  66. - mode: 440
  67. - source: salt://nginx/templates/upstart.jinja
  68. - require:
  69. - pkg: nginx
  70. - file: nginx-old-init
  71. - module: nginx-old-init
  72. {% endif %}
  73. service:
  74. - running
  75. - enable: True
  76. - restart: True
  77. - watch:
  78. {% if use_upstart %}
  79. - file: nginx
  80. {% endif %}
  81. - file: /etc/nginx/nginx.conf
  82. - file: /etc/nginx/conf.d/default.conf
  83. - file: /etc/nginx/conf.d/example_ssl.conf
  84. - pkg: nginx
  85. # Create 'service' symlink for tab completion.
  86. {% if use_upstart %}
  87. /etc/init.d/nginx:
  88. file.symlink:
  89. - target: /lib/init/upstart-job
  90. {% endif %}