Saltstack Official Nginx Formula
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 grains.get('os_family') == 'Debian' %}
  38. {% set repo_source = pillar.get('nginx', {}).get('repo_source', 'default') %}
  39. {% set use_ppa = repo_source == 'ppa' and grains.get('os') == 'Ubuntu' %}
  40. {% set use_official = repo_source == 'official' and grains.get('os') in ('Ubuntu', 'Debian') %}
  41. nginx-ppa-repo:
  42. pkgrepo:
  43. {%- if use_ppa %}
  44. - managed
  45. {%- else %}
  46. - absent
  47. {%- endif %}
  48. - humanname: nginx-ppa-{{ grains['oscodename'] }}
  49. - name: deb http://ppa.launchpad.net/nginx/{{ pillar.get('nginx', {}).get('repo_version', 'stable') }}/ubuntu {{ grains['oscodename'] }} main
  50. - file: /etc/apt/sources.list.d/nginx-{{ pillar.get('nginx', {}).get('repo_version', 'stable') }}-{{ grains['oscodename'] }}.list
  51. - dist: {{ grains['oscodename'] }}
  52. - keyid: C300EE8C
  53. - keyserver: keyserver.ubuntu.com
  54. - require_in:
  55. - pkg: nginx
  56. - watch_in:
  57. - pkg: nginx
  58. nginx-official-repo:
  59. pkgrepo:
  60. {%- if use_official %}
  61. - managed
  62. {%- else %}
  63. - absent
  64. {%- endif %}
  65. - humanname: nginx apt repo
  66. - name: deb http://nginx.org/packages/{{ grains['os'].lower() }}/ {{ grains['oscodename'] }} nginx
  67. - file: /etc/apt/sources.list.d/nginx-official-{{ grains['oscodename'] }}.list
  68. - keyid: ABF5BD827BD9BF62
  69. - keyserver: keyserver.ubuntu.com
  70. - require_in:
  71. - pkg: nginx
  72. - watch_in:
  73. - pkg: nginx
  74. {% endif %}
  75. nginx:
  76. pkg.installed:
  77. - name: {{ nginx.package }}
  78. {% if use_upstart %}
  79. file:
  80. - managed
  81. - name: /etc/init/nginx.conf
  82. - template: jinja
  83. - user: root
  84. - group: root
  85. - mode: 440
  86. - source: salt://nginx/templates/upstart.jinja
  87. - require:
  88. - pkg: nginx
  89. - file: nginx-old-init
  90. - module: nginx-old-init
  91. {% endif %}
  92. service:
  93. - running
  94. - enable: True
  95. - restart: True
  96. - watch:
  97. {% if use_upstart %}
  98. - file: nginx
  99. {% endif %}
  100. - file: /etc/nginx/nginx.conf
  101. - file: /etc/nginx/conf.d/default.conf
  102. - file: /etc/nginx/conf.d/example_ssl.conf
  103. - pkg: nginx
  104. # Create 'service' symlink for tab completion.
  105. {% if use_upstart %}
  106. /etc/init.d/nginx:
  107. file.symlink:
  108. - target: /lib/init/upstart-job
  109. - force: True
  110. {% endif %}