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.

преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. {% from "nginx/map.jinja" import nginx with context %}
  2. {% set use_upstart = salt['pillar.get']('nginx:use_upstart', nginx['use_upstart']) %}
  3. {% if use_upstart %}
  4. nginx-old-init:
  5. file.rename:
  6. - name: /usr/share/nginx/init.d
  7. - source: /etc/init.d/nginx
  8. - require_in:
  9. - file: nginx
  10. - require:
  11. - pkg: nginx
  12. - force: True
  13. {% if grains.get('os_family') == 'Debian' %}
  14. # Don't dpkg-divert if we are not Debian based!
  15. cmd.wait:
  16. - name: dpkg-divert --divert /usr/share/nginx/init.d --add /etc/init.d/nginx
  17. - require:
  18. - module: nginx-old-init
  19. - watch:
  20. - file: nginx-old-init
  21. - require_in:
  22. - file: nginx
  23. {% endif %}
  24. module.wait:
  25. - name: cmd.run
  26. - cmd: kill `cat /var/run/nginx.pid`
  27. - watch:
  28. - file: nginx-old-init
  29. - require_in:
  30. - file: nginx
  31. # RedHat requires the init file in place to chkconfig off
  32. {% if nginx['disable_before_rename'] %}
  33. {% set _in = '_in' %}
  34. {% else %}
  35. {% set _in = '' %}
  36. {% endif %}
  37. nginx-old-init-disable:
  38. cmd.run:
  39. - name: {{ nginx.old_init_disable }}
  40. - require{{ _in }}:
  41. - module: nginx-old-init
  42. - onlyif: [ -f /etc/init.d/nginx ]
  43. {% endif %}
  44. {% if grains.get('os_family') == 'Debian' %}
  45. {% set repo_source = pillar.get('nginx', {}).get('repo_source', 'default') %}
  46. {% set use_ppa = repo_source == 'ppa' and grains.get('os') == 'Ubuntu' %}
  47. {% set use_official = repo_source == 'official' and grains.get('os') in ('Ubuntu', 'Debian') %}
  48. nginx-ppa-repo:
  49. pkgrepo:
  50. {%- if use_ppa %}
  51. - managed
  52. {%- else %}
  53. - absent
  54. {%- endif %}
  55. - humanname: nginx-ppa-{{ grains['oscodename'] }}
  56. - name: deb http://ppa.launchpad.net/nginx/{{ pillar.get('nginx', {}).get('repo_version', 'stable') }}/ubuntu {{ grains['oscodename'] }} main
  57. - file: /etc/apt/sources.list.d/nginx-{{ pillar.get('nginx', {}).get('repo_version', 'stable') }}-{{ grains['oscodename'] }}.list
  58. - dist: {{ grains['oscodename'] }}
  59. - keyid: C300EE8C
  60. - keyserver: keyserver.ubuntu.com
  61. - require_in:
  62. - pkg: nginx
  63. - watch_in:
  64. - pkg: nginx
  65. nginx-official-repo:
  66. pkgrepo:
  67. {%- if use_official %}
  68. - managed
  69. {%- else %}
  70. - absent
  71. {%- endif %}
  72. - humanname: nginx apt repo
  73. - name: deb http://nginx.org/packages/{{ grains['os'].lower() }}/ {{ grains['oscodename'] }} nginx
  74. - file: /etc/apt/sources.list.d/nginx-official-{{ grains['oscodename'] }}.list
  75. - keyid: ABF5BD827BD9BF62
  76. - keyserver: keyserver.ubuntu.com
  77. - require_in:
  78. - pkg: nginx
  79. - watch_in:
  80. - pkg: nginx
  81. {% endif %}
  82. nginx:
  83. pkg.installed:
  84. - name: {{ nginx.package }}
  85. {% if use_upstart %}
  86. file.managed:
  87. - name: /etc/init/nginx.conf
  88. - template: jinja
  89. - user: root
  90. - group: root
  91. - mode: 440
  92. - source: salt://nginx/templates/upstart.jinja
  93. - require:
  94. - pkg: nginx
  95. - file: nginx-old-init
  96. - module: nginx-old-init
  97. {% endif %}
  98. service.running:
  99. - enable: True
  100. - restart: True
  101. - watch:
  102. {% if use_upstart %}
  103. - file: nginx
  104. {% endif %}
  105. {% set conf_dir = salt['pillar.get']('nginx:conf_dir', '/etc/nginx') %}
  106. - file: {{ conf_dir }}/nginx.conf
  107. - file: {{ conf_dir }}/conf.d/default.conf
  108. - file: {{ conf_dir }}/conf.d/example_ssl.conf
  109. - pkg: nginx
  110. # Create 'service' symlink for tab completion.
  111. # This is not supported in os_family RedHat and likely only works in
  112. # Debian-based distros
  113. {% if use_upstart and grains['os_family'] == 'Debian' %}
  114. /etc/init.d/nginx:
  115. file.symlink:
  116. - target: /lib/init/upstart-job
  117. - force: True
  118. {% endif %}