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.

init.sls 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. include:
  2. - nginx.users
  3. {% for filename in ('default', 'example_ssl') %}
  4. /etc/nginx/conf.d/{{ filename }}.conf:
  5. file.absent
  6. {% endfor %}
  7. /etc/nginx/nginx.conf:
  8. file:
  9. - managed
  10. - template: jinja
  11. - user: root
  12. - group: root
  13. - mode: 440
  14. - source: salt://nginx/templates/config.jinja
  15. - require:
  16. - pkg: nginx
  17. nginx-old-init:
  18. file:
  19. - rename
  20. - name: /usr/share/nginx/init.d
  21. - source: /etc/init.d/nginx
  22. - require:
  23. - pkg: nginx
  24. cmd:
  25. - wait
  26. - name: dpkg-divert --divert /usr/share/nginx/init.d --add /etc/init.d/nginx
  27. - require:
  28. - module: nginx-old-init
  29. - watch:
  30. - file: nginx-old-init
  31. module:
  32. - wait
  33. - name: cmd.run
  34. - cmd: kill `cat /var/run/nginx.pid`
  35. - watch:
  36. - file: nginx-old-init
  37. nginx-old-init-disable:
  38. cmd:
  39. - wait
  40. - name: update-rc.d -f nginx remove
  41. - require:
  42. - module: nginx-old-init
  43. - watch:
  44. - file: nginx-old-init
  45. {% set logger_types = ('access', 'error') %}
  46. {% for log_type in logger_types %}
  47. /var/log/nginx/{{ log_type }}.log:
  48. file.absent
  49. nginx-logger-{{ log_type }}:
  50. file:
  51. - managed
  52. - name: /etc/init/nginx-logger-{{ log_type }}.conf
  53. - template: jinja
  54. - user: root
  55. - group: root
  56. - mode: 440
  57. - source: salt://nginx/templates/upstart-logger.jinja
  58. - context:
  59. type: {{ log_type }}
  60. service:
  61. - running
  62. - enable: True
  63. - require:
  64. - file: nginx-logger-{{ log_type }}
  65. - pkg: nginx
  66. {% endfor %}
  67. /etc/logrotate.d/nginx:
  68. file:
  69. - absent
  70. nginx:
  71. pkg:
  72. - installed
  73. - name: nginx
  74. file:
  75. - managed
  76. - name: /etc/init/nginx.conf
  77. - template: jinja
  78. - user: root
  79. - group: root
  80. - mode: 440
  81. - source: salt://nginx/templates/upstart.jinja
  82. - require:
  83. - pkg: nginx
  84. - file: nginx-old-init
  85. - module: nginx-old-init
  86. service:
  87. - running
  88. - enable: True
  89. - watch:
  90. - file: nginx
  91. - file: /etc/nginx/nginx.conf
  92. - file: /etc/nginx/conf.d/default.conf
  93. - file: /etc/nginx/conf.d/example_ssl.conf
  94. - pkg: nginx
  95. - require:
  96. {% for log_type in logger_types %}
  97. - service: nginx-logger-{{ log_type }}
  98. {% endfor %}