Saltstack Official Nginx Formula
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

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