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.

203 lines
7.3KB

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