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.

149 lines
4.8KB

  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. 'service': 'nginx',
  11. 'webuser': 'www-data',
  12. 'conf_file': '/etc/nginx/nginx.conf',
  13. 'vhost_available': '/etc/nginx/sites-available',
  14. 'vhost_enabled': '/etc/nginx/sites-enabled',
  15. 'vhost_use_symlink': True,
  16. 'vhost_overwrite': True,
  17. 'pid_file': '/run/nginx.pid',
  18. },
  19. 'CentOS': {
  20. 'package': 'nginx',
  21. 'service': 'nginx',
  22. 'webuser': 'nginx',
  23. 'conf_file': '/etc/nginx/nginx.conf',
  24. 'vhost_available': '/etc/nginx/conf.d',
  25. 'vhost_enabled': '/etc/nginx/conf.d',
  26. 'vhost_use_symlink': False,
  27. 'vhost_overwrite': True,
  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. 'service': 'nginx',
  36. 'webuser': 'nginx',
  37. 'conf_file': '/etc/nginx/nginx.conf',
  38. 'vhost_available': '/etc/nginx/conf.d',
  39. 'vhost_enabled': '/etc/nginx/conf.d',
  40. 'vhost_use_symlink': False,
  41. 'vhost_overwrite': True,
  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. },
  47. 'Suse': {
  48. 'package': 'nginx',
  49. 'service': 'nginx',
  50. 'webuser': 'nginx',
  51. 'conf_file': '/etc/nginx/nginx.conf',
  52. 'vhost_available': '/etc/nginx/conf.d',
  53. 'vhost_enabled': '/etc/nginx/conf.d',
  54. 'vhost_use_symlink': False,
  55. 'vhost_overwrite': True,
  56. 'pid_file': '/run/nginx.pid',
  57. 'gpg_check': True,
  58. 'gpg_key': 'http://download.opensuse.org/repositories/server:/http/openSUSE_13.2/repodata/repomd.xml.key'
  59. },
  60. 'Arch': {
  61. 'package': 'nginx',
  62. 'service': 'nginx',
  63. 'webuser': 'http',
  64. 'conf_file': '/etc/nginx/nginx.conf',
  65. 'vhost_available': '/etc/nginx/sites-available',
  66. 'vhost_enabled': '/etc/nginx/sites-enabled',
  67. 'vhost_use_symlink': True,
  68. 'vhost_overwrite': True,
  69. },
  70. 'Gentoo': {
  71. 'package': 'www-servers/nginx',
  72. 'service': 'nginx',
  73. 'webuser': 'nginx',
  74. 'conf_file': '/etc/nginx/nginx.conf',
  75. 'vhost_available': '/etc/nginx/sites-available',
  76. 'vhost_enabled': '/etc/nginx/sites-enabled',
  77. 'vhost_use_symlink': True,
  78. 'vhost_overwrite': True,
  79. },
  80. }, default='Debian' ),
  81. 'install_from_source': False,
  82. 'install_from_ppa': False,
  83. 'install_from_repo': False,
  84. 'ppa_version': 'stable',
  85. 'source_version': '1.10.0',
  86. 'source_hash': '8ed647c3dd65bc4ced03b0e0f6bf9e633eff6b01bac772bcf97077d58bc2be4d',
  87. 'source': {
  88. 'opts': {},
  89. 'modules': {}
  90. },
  91. 'package': {
  92. 'opts': {},
  93. },
  94. 'service': {
  95. 'enable': True,
  96. 'opts': {},
  97. },
  98. 'server': {
  99. 'opts': {},
  100. 'config': {
  101. 'worker_processes': 4,
  102. 'events': {
  103. 'worker_connections': 768,
  104. },
  105. 'http': {
  106. 'sendfile': 'on',
  107. 'tcp_nopush': 'on',
  108. 'tcp_nodelay': 'on',
  109. 'keepalive_timeout': '65',
  110. 'types_hash_max_size': '2048',
  111. 'default_type': 'application/octet-stream',
  112. 'access_log': '/var/log/nginx/access.log',
  113. 'error_log': '/var/log/nginx/error.log',
  114. 'gzip': 'off',
  115. 'gzip_disable': '"msie6"',
  116. 'include': [
  117. '/etc/nginx/mime.types',
  118. '/etc/nginx/conf.d/*.conf',
  119. '/etc/nginx/sites-enabled/*',
  120. ],
  121. },
  122. },
  123. },
  124. 'vhosts': {
  125. 'disabled_postfix': '.disabled',
  126. 'symlink_opts': {},
  127. 'rename_opts': {},
  128. 'managed_opts': {},
  129. 'dir_opts': {
  130. 'makedirs': True,
  131. },
  132. 'managed': {},
  133. },
  134. }, merge=True) %}
  135. {% if 'user' not in nginx.server.config %}
  136. {% do nginx.server.config.update({
  137. 'user': nginx.lookup.webuser,
  138. })%}
  139. {% endif %}
  140. {% if 'pid' not in nginx.server.config and 'pid_file' in nginx.lookup %}
  141. {% do nginx.server.config.update({
  142. 'pid': nginx.lookup.pid_file,
  143. })%}
  144. {% endif %}