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.

137 lines
4.4KB

  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. 'CentOS': {
  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. 'rh_os_releasever': '$releasever',
  28. 'gpg_check': False,
  29. 'gpg_key': 'http://nginx.org/keys/nginx_signing.key',
  30. },
  31. 'RedHat': {
  32. 'package': 'nginx',
  33. 'service': 'nginx',
  34. 'webuser': 'nginx',
  35. 'conf_file': '/etc/nginx/nginx.conf',
  36. 'vhost_available': '/etc/nginx/conf.d',
  37. 'vhost_enabled': '/etc/nginx/conf.d',
  38. 'vhost_use_symlink': False,
  39. 'pid_file': '/run/nginx.pid',
  40. 'rh_os_releasever': '$releasever',
  41. 'gpg_check': False,
  42. 'gpg_key': 'http://nginx.org/keys/nginx_signing.key',
  43. },
  44. 'Suse': {
  45. 'package': 'nginx',
  46. 'service': 'nginx',
  47. 'webuser': 'nginx',
  48. 'conf_file': '/etc/nginx/nginx.conf',
  49. 'vhost_available': '/etc/nginx/conf.d',
  50. 'vhost_enabled': '/etc/nginx/conf.d',
  51. 'vhost_use_symlink': False,
  52. 'pid_file': '/run/nginx.pid',
  53. 'gpg_check': True,
  54. 'gpg_key': 'http://download.opensuse.org/repositories/server:/http/openSUSE_13.2/repodata/repomd.xml.key'
  55. },
  56. 'Arch': {
  57. 'package': 'nginx',
  58. 'service': 'nginx',
  59. 'webuser': 'http',
  60. 'conf_file': '/etc/nginx/nginx.conf',
  61. 'vhost_available': '/etc/nginx/sites-available',
  62. 'vhost_enabled': '/etc/nginx/sites-enabled',
  63. 'vhost_use_symlink': True,
  64. },
  65. 'Gentoo': {
  66. 'package': 'www-servers/nginx',
  67. 'service': 'nginx',
  68. 'webuser': 'nginx',
  69. 'conf_file': '/etc/nginx/nginx.conf',
  70. 'vhost_available': '/etc/nginx/sites-available',
  71. 'vhost_enabled': '/etc/nginx/sites-enabled',
  72. 'vhost_use_symlink': True,
  73. },
  74. }, default='Debian' ),
  75. 'install_from_source': False,
  76. 'install_from_ppa': False,
  77. 'install_from_repo': False,
  78. 'ppa_version': 'stable',
  79. 'package': {
  80. 'opts': {},
  81. },
  82. 'service': {
  83. 'enable': True,
  84. 'opts': {},
  85. },
  86. 'server': {
  87. 'opts': {},
  88. 'config': {
  89. 'worker_processes': 4,
  90. 'events': {
  91. 'worker_connections': 768,
  92. },
  93. 'http': {
  94. 'sendfile': 'on',
  95. 'tcp_nopush': 'on',
  96. 'tcp_nodelay': 'on',
  97. 'keepalive_timeout': '65',
  98. 'types_hash_max_size': '2048',
  99. 'default_type': 'application/octet-stream',
  100. 'access_log': '/var/log/nginx/access.log',
  101. 'error_log': '/var/log/nginx/error.log',
  102. 'gzip': 'off',
  103. 'gzip_disable': '"msie6"',
  104. 'include': [
  105. '/etc/nginx/mime.types',
  106. '/etc/nginx/conf.d/*.conf',
  107. '/etc/nginx/sites-enabled/*',
  108. ],
  109. },
  110. },
  111. },
  112. 'vhosts': {
  113. 'disabled_postfix': '.disabled',
  114. 'symlink_opts': {},
  115. 'rename_opts': {},
  116. 'managed_opts': {},
  117. 'dir_opts': {
  118. 'makedirs': True,
  119. },
  120. 'managed': {},
  121. },
  122. }, merge=True) %}
  123. {% if 'user' not in nginx.server.config %}
  124. {% do nginx.server.config.update({
  125. 'user': nginx.lookup.webuser,
  126. })%}
  127. {% endif %}
  128. {% if 'pid' not in nginx.server.config and 'pid_file' in nginx.lookup %}
  129. {% do nginx.server.config.update({
  130. 'pid': nginx.lookup.pid_file,
  131. })%}
  132. {% endif %}