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

201 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/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. '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. 'openssl_package': 'openssl',
  108. 'pid_file': '/var/run/nginx.pid',
  109. },
  110. }, default='Debian' ),
  111. 'install_from_source': False,
  112. 'install_from_ppa': False,
  113. 'install_from_repo': False,
  114. 'install_from_phusionpassenger': False,
  115. 'check_config_before_apply': False,
  116. 'ppa_version': 'stable',
  117. 'source_version': '1.10.0',
  118. 'source_hash': '8ed647c3dd65bc4ced03b0e0f6bf9e633eff6b01bac772bcf97077d58bc2be4d',
  119. 'source': {
  120. 'opts': {},
  121. },
  122. 'package': {
  123. 'opts': {},
  124. },
  125. 'service': {
  126. 'enable': True,
  127. 'opts': {},
  128. },
  129. 'server': {
  130. 'opts': {},
  131. 'config': {
  132. 'worker_processes': 'auto',
  133. 'events': {
  134. 'worker_connections': 512,
  135. },
  136. 'http': {
  137. 'sendfile': 'on',
  138. 'tcp_nopush': 'on',
  139. 'tcp_nodelay': 'on',
  140. 'keepalive_timeout': '65',
  141. 'types_hash_max_size': '2048',
  142. 'default_type': 'application/octet-stream',
  143. 'access_log': '/var/log/nginx/access.log',
  144. 'error_log': '/var/log/nginx/error.log',
  145. 'gzip': 'off',
  146. 'gzip_disable': '"msie6"',
  147. 'include': [
  148. 'mime.types',
  149. 'conf.d/*.conf',
  150. 'sites-enabled/*',
  151. ],
  152. },
  153. },
  154. },
  155. 'servers': {
  156. 'disabled_postfix': '.disabled',
  157. 'symlink_opts': {},
  158. 'rename_opts': {},
  159. 'managed_opts': {
  160. 'makedirs': True,
  161. },
  162. 'dir_opts': {
  163. 'makedirs': True,
  164. },
  165. 'managed': {},
  166. 'purge_servers_config': False,
  167. },
  168. 'passenger': {
  169. 'passenger_root': '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini',
  170. 'passenger_ruby': '/usr/bin/ruby',
  171. },
  172. }, merge=True) %}
  173. {% if 'user' not in nginx.server.config %}
  174. {% do nginx.server.config.update({
  175. 'user': nginx.lookup.webuser,
  176. }) %}
  177. {% endif %}
  178. {% if 'pid' not in nginx.server.config and 'pid_file' in nginx.lookup %}
  179. {% do nginx.server.config.update({
  180. 'pid': nginx.lookup.pid_file,
  181. }) %}
  182. {% endif %}
  183. {% if salt['grains.get']('os_family') == 'RedHat' %}
  184. {% do nginx.passenger.update({
  185. 'passenger_root': '/usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini',
  186. 'passenger_instance_registry_dir': '/var/run/passenger-instreg',
  187. }) %}
  188. {% if 'osfinger' in grains and salt['grains.get']('osfinger') == 'CentOS-6' %}
  189. {% do nginx.server.config.update({
  190. 'pid': '/var/run/nginx.pid',
  191. }) %}
  192. {% do nginx.passenger.update({
  193. 'passenger_root': '/usr/lib/ruby/1.8/phusion_passenger/locations.ini',
  194. }) %}
  195. {% endif %}
  196. {% endif %}