Saltstack Official Nginx Formula
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

189 lines
6.5KB

  1. {% macro sls_block(dict) %}
  2. {% for key, value in dict.items() %}
  3. - {{ key }}: {{ value|json() }}
  4. {% endfor %}
  5. {% endmacro %}
  6. {% set nginx = salt['pillar.get']('nginx:ng', {
  7. 'lookup': salt['grains.filter_by']({
  8. 'Debian': {
  9. 'package': 'nginx',
  10. 'passenger_package': 'passenger',
  11. 'passenger_config_file': '/etc/nginx/conf.d/passenger.conf',
  12. 'service': 'nginx',
  13. 'webuser': 'www-data',
  14. 'conf_file': '/etc/nginx/nginx.conf',
  15. 'server_available': '/etc/nginx/sites-available',
  16. 'server_enabled': '/etc/nginx/sites-enabled',
  17. 'server_use_symlink': True,
  18. 'pid_file': '/run/nginx.pid',
  19. 'openssl_package': 'openssl',
  20. },
  21. 'CentOS': {
  22. 'package': 'nginx',
  23. 'passenger_package': 'passenger',
  24. 'passenger_config_file': '/etc/nginx/conf.d/passenger.conf',
  25. 'service': 'nginx',
  26. 'webuser': 'nginx',
  27. 'conf_file': '/etc/nginx/nginx.conf',
  28. 'server_available': '/etc/nginx/conf.d',
  29. 'server_enabled': '/etc/nginx/conf.d',
  30. 'server_use_symlink': False,
  31. 'pid_file': '/run/nginx.pid',
  32. 'rh_os_releasever': '$releasever',
  33. 'gpg_check': False,
  34. 'gpg_key': 'http://nginx.org/keys/nginx_signing.key',
  35. 'openssl_package': 'openssl',
  36. },
  37. 'RedHat': {
  38. 'package': 'nginx',
  39. 'passenger_package': 'passenger',
  40. 'passenger_config_file': '/etc/nginx/conf.d/passenger.conf',
  41. 'service': 'nginx',
  42. 'webuser': 'nginx',
  43. 'conf_file': '/etc/nginx/nginx.conf',
  44. 'server_available': '/etc/nginx/conf.d',
  45. 'server_enabled': '/etc/nginx/conf.d',
  46. 'server_use_symlink': False,
  47. 'pid_file': '/run/nginx.pid',
  48. 'rh_os_releasever': '$releasever',
  49. 'gpg_check': False,
  50. 'gpg_key': 'http://nginx.org/keys/nginx_signing.key',
  51. 'passenger': {
  52. 'passenger_root': '/usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini',
  53. 'passenger_instance_registry_dir': ' /var/run/passenger-instreg',
  54. 'passenger_ruby': '/usr/bin/ruby',
  55. },
  56. 'openssl_package': 'openssl',
  57. },
  58. 'Suse': {
  59. 'package': 'nginx',
  60. 'service': 'nginx',
  61. 'webuser': 'nginx',
  62. 'conf_file': '/etc/nginx/nginx.conf',
  63. 'server_available': '/etc/nginx/conf.d',
  64. 'server_enabled': '/etc/nginx/conf.d',
  65. 'server_use_symlink': False,
  66. 'pid_file': '/run/nginx.pid',
  67. 'gpg_check': True,
  68. 'gpg_key': 'http://download.opensuse.org/repositories/server:/http/openSUSE_13.2/repodata/repomd.xml.key',
  69. 'openssl_package': 'openssl',
  70. },
  71. 'Arch': {
  72. 'package': 'nginx',
  73. 'service': 'nginx',
  74. 'webuser': 'http',
  75. 'conf_file': '/etc/nginx/nginx.conf',
  76. 'server_available': '/etc/nginx/sites-available',
  77. 'server_enabled': '/etc/nginx/sites-enabled',
  78. 'server_use_symlink': True,
  79. 'openssl_package': 'openssl',
  80. },
  81. 'Gentoo': {
  82. 'package': 'www-servers/nginx',
  83. 'service': 'nginx',
  84. 'webuser': 'nginx',
  85. 'conf_file': '/etc/nginx/nginx.conf',
  86. 'server_available': '/etc/nginx/sites-available',
  87. 'server_enabled': '/etc/nginx/sites-enabled',
  88. 'server_use_symlink': True,
  89. 'openssl_package': 'dev-libs/openssl',
  90. },
  91. 'FreeBSD': {
  92. 'package': 'nginx',
  93. 'passenger_package': 'passenger',
  94. 'service': 'nginx',
  95. 'webuser': 'www',
  96. 'conf_file': '/usr/local/etc/nginx/nginx.conf',
  97. 'server_available': '/usr/local/etc/nginx/sites-available',
  98. 'server_enabled': '/usr/local/etc/nginx/sites-enabled',
  99. 'server_use_symlink': True,
  100. 'pid_file': '/var/run/nginx.pid',
  101. },
  102. }, default='Debian' ),
  103. 'install_from_source': False,
  104. 'install_from_ppa': False,
  105. 'install_from_repo': False,
  106. 'install_from_phusionpassenger': False,
  107. 'ppa_version': 'stable',
  108. 'source_version': '1.10.0',
  109. 'source_hash': '8ed647c3dd65bc4ced03b0e0f6bf9e633eff6b01bac772bcf97077d58bc2be4d',
  110. 'source': {
  111. 'opts': {},
  112. },
  113. 'package': {
  114. 'opts': {},
  115. },
  116. 'service': {
  117. 'enable': True,
  118. 'opts': {},
  119. },
  120. 'server': {
  121. 'opts': {},
  122. 'config': {
  123. 'worker_processes': 4,
  124. 'events': {
  125. 'worker_connections': 768,
  126. },
  127. 'http': {
  128. 'sendfile': 'on',
  129. 'tcp_nopush': 'on',
  130. 'tcp_nodelay': 'on',
  131. 'keepalive_timeout': '65',
  132. 'types_hash_max_size': '2048',
  133. 'default_type': 'application/octet-stream',
  134. 'access_log': '/var/log/nginx/access.log',
  135. 'error_log': '/var/log/nginx/error.log',
  136. 'gzip': 'off',
  137. 'gzip_disable': '"msie6"',
  138. 'include': [
  139. 'mime.types',
  140. 'conf.d/*.conf',
  141. 'sites-enabled/*',
  142. ],
  143. },
  144. },
  145. },
  146. 'servers': {
  147. 'disabled_postfix': '.disabled',
  148. 'symlink_opts': {},
  149. 'rename_opts': {},
  150. 'managed_opts': {},
  151. 'dir_opts': {
  152. 'makedirs': True,
  153. },
  154. 'managed': {},
  155. },
  156. 'passenger': {
  157. 'passenger_root': '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini',
  158. 'passenger_ruby': '/usr/bin/ruby',
  159. },
  160. }, merge=True) %}
  161. {% if 'user' not in nginx.server.config %}
  162. {% do nginx.server.config.update({
  163. 'user': nginx.lookup.webuser,
  164. })%}
  165. {% endif %}
  166. {% if 'pid' not in nginx.server.config and 'pid_file' in nginx.lookup %}
  167. {% do nginx.server.config.update({
  168. 'pid': nginx.lookup.pid_file,
  169. })%}
  170. {% endif %}
  171. {% if salt['grains.get']('os_family') == 'RedHat' %}
  172. {% do nginx.passenger.update({
  173. 'passenger_root': '/usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini',
  174. 'passenger_instance_registry_dir': '/var/run/passenger-instreg',
  175. })%}
  176. {% if salt['grains.get']('osfinger') == 'CentOS-6' %}
  177. {% do nginx.server.config.update({
  178. 'pid': '/var/run/nginx.pid',
  179. })%}
  180. {% do nginx.passenger.update({
  181. 'passenger_root': '/usr/lib/ruby/1.8/phusion_passenger/locations.ini',
  182. })%}
  183. {% endif %}
  184. {% endif %}