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

199 lines
7.1KB

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