Saltstack Official Nginx Formula
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

118 líneas
2.9KB

  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/stable/ubuntu {{ grains['oscodename'] }} main
  50. - file: /etc/apt/sources.list.d/nginx-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. {% endif %}