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.

82 lines
2.3KB

  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. },
  17. 'RedHat': {
  18. 'package': 'nginx',
  19. 'service': 'nginx',
  20. 'webuser': 'nginx',
  21. 'conf_file': '/etc/nginx/nginx.conf',
  22. 'vhost_available': '/etc/nginx/conf.d',
  23. 'vhost_enabled': '/etc/nginx/conf.d',
  24. 'vhost_use_symlink': False,
  25. },
  26. }, default='Debian' ),
  27. 'install_from_source': False,
  28. 'install_from_ppa': False,
  29. 'ppa_version': 'stable',
  30. 'package': {
  31. 'opts': {},
  32. },
  33. 'service': {
  34. 'enable': True,
  35. 'opts': {},
  36. },
  37. 'server': {
  38. 'opts': {},
  39. 'config': {
  40. 'worker_processes': 4,
  41. 'pid': '/run/nginx.pid',
  42. 'events': {
  43. 'worker_connections': 768,
  44. },
  45. 'http': {
  46. 'sendfile': 'on',
  47. 'tcp_nopush': 'on',
  48. 'tcp_nodelay': 'on',
  49. 'keepalive_timeout': '65',
  50. 'types_hash_max_size': '2048',
  51. 'default_type': 'application/octet-stream',
  52. 'access_log': '/var/log/nginx/access.log',
  53. 'error_log': '/var/log/nginx/error.log',
  54. 'gzip': 'off',
  55. 'gzip_disable': '"msie6"',
  56. 'include': [
  57. '/etc/nginx/mime.types',
  58. '/etc/nginx/conf.d/*.conf',
  59. '/etc/nginx/sites-enabled/*',
  60. ],
  61. },
  62. },
  63. },
  64. 'vhosts': {
  65. 'disabled_postfix': '.disabled',
  66. 'symlink_opts': {},
  67. 'rename_opts': {},
  68. 'managed_opts': {},
  69. 'dir_opts': {
  70. 'makedirs': True,
  71. },
  72. 'managed': {},
  73. },
  74. }, merge=True) %}
  75. {% if 'user' not in nginx.server.config %}
  76. {% do nginx.server.config.update({
  77. 'user': nginx.lookup.webuser,
  78. })%}
  79. {% endif %}