Saltstack Official Nginx Formula
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

215 行
7.7KB

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