Saltstack Official Nginx Formula
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

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