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.

181 líneas
4.6KB

  1. include:
  2. - nginx.common
  3. {% set nginx = pillar.get('nginx', {}) -%}
  4. {% set version = nginx.get('version', '1.5.2') -%}
  5. {% set checksum = nginx.get('checksum', 'sha1=3546be28a72251f8823ab6be6a1180d300d06f76') -%}
  6. {% set home = nginx.get('home', '/var/www') -%}
  7. {% set source = nginx.get('source_root', '/usr/local/src') -%}
  8. {% set nginx_package = source + '/nginx-' + version + '.tar.gz' -%}
  9. {% set nginx_home = home + "/nginx-" + version -%}
  10. {% set nginx_modules_dir = source + "/nginx-modules" -%}
  11. {% if nginx['with_luajit'] -%}
  12. include:
  13. - nginx.luajit2
  14. {% endif -%}
  15. {% if nginx['with_openresty'] -%}
  16. include:
  17. - nginx.openresty
  18. {% endif -%}
  19. nginx_group:
  20. group.present:
  21. - name: www-data
  22. nginx_user:
  23. file.directory:
  24. - name: {{ home }}
  25. - user: www-data
  26. - group: www-data
  27. - mode: 0755
  28. - require:
  29. - user: nginx_user
  30. - group: nginx_group
  31. user.present:
  32. - name: www-data
  33. - home: {{ home }}
  34. - groups:
  35. - www-data
  36. - require:
  37. - group: nginx_group
  38. get-nginx:
  39. pkg.installed:
  40. - names:
  41. - libpcre3-dev
  42. - build-essential
  43. - libssl-dev
  44. file.managed:
  45. - name: {{ nginx_package }}
  46. - source: http://nginx.org/download/nginx-{{ version }}.tar.gz
  47. - source_hash: {{ checksum }}
  48. cmd.wait:
  49. - cwd: {{ source }}
  50. - name: tar -zxf {{ nginx_package }} -C {{ home }}
  51. - require:
  52. - file: nginx_user
  53. - pkg: get-nginx
  54. - watch:
  55. - file: get-nginx
  56. {% for name, module in nginx.get('modules', {}) -%}
  57. get-nginx-{{name}}:
  58. file.managed:
  59. - name: {{ nginx_modules_dir }}/{{name}}.tar.gz
  60. - source: {{ module['source'] }}
  61. - source_hash: {{ module['source_hash'] }}
  62. - require:
  63. - file: nginx_user
  64. cmd.wait:
  65. - cwd: {{ nginx_home }}
  66. - names:
  67. - tar -zxf {{ nginx_modules_dir }}/{{name}}.tar.gz -C {{ nginx_modules_dir }}/{{name}}
  68. - watch:
  69. - file: get-nginx
  70. - require_in:
  71. - cmd: make-nginx
  72. {% endfor -%}
  73. {% if install_luajit -%}
  74. {% endif -%}
  75. get-ngx_devel_kit:
  76. file.managed:
  77. - name: {{ source }}/ngx_devel_kit.tar.gz
  78. - source: https://github.com/simpl/ngx_devel_kit/archive/v0.2.18.tar.gz
  79. - source_hash: sha1=e21ba642f26047661ada678b21eef001ee2121d8
  80. cmd.wait:
  81. - cwd: {{ nginx_home }}
  82. - name: tar -zxf {{ source }}/ngx_devel_kit.tar.gz -C {{ source }}
  83. - watch:
  84. - file: get-ngx_devel_kit
  85. get-lua-nginx-module:
  86. file.managed:
  87. - name: {{ source }}/lua-nginx-module.tar.gz
  88. - source: https://github.com/chaoslawful/lua-nginx-module/archive/v0.8.3rc1.tar.gz
  89. - source_hash: sha1=49b2fa946517fb2e9b26185d418570e98ff5ff51
  90. cmd.wait:
  91. - cwd: {{ nginx_home }}
  92. - name: tar -zxf {{ source }}/lua-nginx-module.tar.gz -C {{ source }}
  93. - watch:
  94. - file: get-lua-nginx-module
  95. {{ home }}:
  96. file.directory:
  97. - user: www-data
  98. - group: www-data
  99. - makedirs: True
  100. - mode: 0755
  101. {% for dir in ('body', 'proxy', 'fastcgi') -%}
  102. {{ home }}-{{dir}}:
  103. file.directory:
  104. - name: {{ home }}/{{dir}}
  105. - user: www-data
  106. - group: www-data
  107. - mode: 0755
  108. - require:
  109. - file: {{ home }}
  110. - require_in:
  111. - service: nginx
  112. {% endfor -%}
  113. nginx:
  114. cmd.wait:
  115. - cwd: {{ nginx_home }}
  116. - names:
  117. - ./configure --conf-path=/etc/nginx/nginx.conf
  118. --sbin-path=/usr/sbin/nginx
  119. --user=www-data
  120. --group=www-data
  121. --prefix=/usr/local/nginx
  122. --error-log-path=/var/log/nginx/error.log
  123. --pid-path=/var/run/nginx.pid
  124. --lock-path=/var/lock/nginx.lock
  125. --http-log-path=/var/log/nginx/access.log
  126. --with-http_dav_module
  127. --http-client-body-temp-path={{ home }}/body
  128. --http-proxy-temp-path={{ home }}/proxy
  129. --with-http_stub_status_module
  130. --http-fastcgi-temp-path={{ home }}/fastcgi
  131. --with-debug
  132. --with-http_ssl_module
  133. {% for name, module in nginx.get('modules', {}) -%}
  134. --add-module={{nginx_modules_dir}}/{{name}} \
  135. --with-pcre --with-ipv6
  136. {% endfor %}
  137. - make -j2 && make install
  138. - watch:
  139. - cmd: get-nginx
  140. - require:
  141. - cmd: get-nginx
  142. - cmd: get-lua-nginx-module
  143. - cmd: get-ngx_devel_kit
  144. - require_in:
  145. - service: nginx
  146. file.managed:
  147. - name: /etc/init/nginx.conf
  148. - template: jinja
  149. - user: root
  150. - group: root
  151. - mode: 440
  152. - source: salt://nginx/templates/upstart.jinja
  153. - require:
  154. - cmd: nginx
  155. service.running:
  156. - enable: True
  157. - watch:
  158. - file: nginx
  159. - file: /etc/nginx/nginx.conf
  160. - file: /etc/nginx/conf.d/default.conf
  161. - file: /etc/nginx/conf.d/example_ssl.conf
  162. - file: nginx
  163. - require:
  164. - cmd: nginx
  165. - file: {{ home }}