Saltstack Official Nginx Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

175 lines
5.9KB

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