Saltstack Official Nginx Formula
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

207 linhas
7.4KB

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