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.

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