Saltstack Official Apache 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.

86 lines
3.5KB

  1. {# Define default values here so the template below can just focus on layout #}
  2. {% from "apache/map.jinja" import apache with context %}
  3. {% set sitename = site.get('ServerName', id) %}
  4. {% set vals = {
  5. 'interface': site.get('interface', '*'),
  6. 'port': site.get('port', '80'),
  7. 'ServerName': sitename,
  8. 'ServerAlias': site.get('ServerAlias', 'www.{0}'.format(sitename)),
  9. 'ServerAdmin': site.get('ServerAdmin', 'webmaster@{0}'.format(sitename)),
  10. 'DirectoryIndex': site.get('DirectoryIndex'),
  11. 'UseCanonicalName': site.get('UseCanonicalName'),
  12. 'LogLevel': site.get('LogLevel', 'warn'),
  13. 'ErrorLog': site.get('ErrorLog', '{0}/{1}-error.log'.format(map.logdir, sitename)),
  14. 'LogFormat': site.get('LogFormat', '"%h %l %u %t \\\"%r\\\" %>s %O"'),
  15. 'CustomLog': site.get('CustomLog', '{0}/{1}-access.log'.format(map.logdir, sitename)),
  16. 'DocumentRoot': site.get('DocumentRoot', '{0}/{1}'.format(map.wwwdir, sitename)),
  17. 'VirtualDocumentRoot': site.get('VirtualDocumentRoot'),
  18. 'Directory_default': '{0}/{1}'.format(map.wwwdir, sitename),
  19. 'Directory': {
  20. 'Options': '-Indexes FollowSymLinks',
  21. 'Order': 'allow,deny',
  22. 'Allow': 'from all',
  23. 'AllowOverride': 'None',
  24. },
  25. } %}
  26. <VirtualHost {{ vals.interface }}:{{ vals.port }}>
  27. ServerName {{ vals.ServerName }}
  28. {% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %}
  29. {% if site.get('ServerAdmin') != False %}ServerAdmin {{ vals.ServerAdmin }}{% endif %}
  30. {% if site.get('DirectoryIndex') %}DirectoryIndex {{ vals.DirectoryIndex }}{% endif %}
  31. {% if site.get('UseCanonicalName') %}UseCanonicalName {{ vals.UseCanonicalName }}{% endif %}
  32. {% if site.get('LogLevel') != False %}LogLevel {{ vals.LogLevel }}{% endif %}
  33. {% if site.get('ErrorLog') != False %}ErrorLog {{ vals.ErrorLog }}{% endif %}
  34. {% if site.get('CustomLog') != False %}CustomLog {{ vals.CustomLog }} {{ vals.LogFormat }}{% endif %}
  35. {% if site.get('DocumentRoot') != False %}DocumentRoot {{ vals.DocumentRoot }}{% endif %}
  36. {% if site.get('VirtualDocumentRoot') %}VirtualDocumentRoot {{ vals.VirtualDocumentRoot }}{% endif %}
  37. {% if site.get('DocumentRoot') != False %}
  38. <Directory {{ vals.DocumentRoot }}>
  39. {% if apache.require_all %}
  40. Require all granted
  41. {% endif %}
  42. </Directory>
  43. {% endif %}
  44. {% for path, dir in site.get('Directory', {}).items() %}
  45. {% set dvals = {
  46. 'Options': dir.get('Options', vals.Directory.Options),
  47. 'Order': dir.get('Order', vals.Directory.Order),
  48. 'Allow': dir.get('Allow', vals.Directory.Allow),
  49. 'Require': dir.get('Require', vals.Directory.Require),
  50. 'AllowOverride': dir.get('AllowOverride', vals.Directory.AllowOverride),
  51. } %}
  52. {% if path == 'default' %}{% set path = vals.Directory_default %}{% endif %}
  53. <Directory "{{ path }}">
  54. {% if dir.get('Options') != False %}Options {{ dvals.Options }}{% endif %}
  55. {% if dir.get('Order') != False %}Order {{ dvals.Order }}{% endif %}
  56. {% if dir.get('Allow') != False %}Allow {{ dvals.Allow }}{% endif %}
  57. {% if dir.get('AllowOverride') != False %}AllowOverride {{ dvals.AllowOverride }}{% endif %}
  58. {% if dir.get('Require') != False %}Require {{dvals.Require}}{% endif %}
  59. {% if dir.get('Formula_Append') %}
  60. {{ dir.Formula_Append|indent(8) }}
  61. {% endif %}
  62. </Directory>
  63. {% endfor %}
  64. {% if site.get('Formula_Append') %}
  65. {{ site.Formula_Append|indent(4) }}
  66. {% endif %}
  67. </VirtualHost>