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.

180 lines
6.1KB

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