Saltstack Official Apache Formula
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

82 lines
3.4KB

  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. 'Require': 'all granted',
  24. 'AllowOverride': 'None',
  25. },
  26. } %}
  27. <VirtualHost {{ vals.interface }}:{{ vals.port }}>
  28. ServerName {{ vals.ServerName }}
  29. {% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %}
  30. {% if site.get('ServerAdmin') != False %}ServerAdmin {{ vals.ServerAdmin }}{% endif %}
  31. {% if site.get('DirectoryIndex') %}DirectoryIndex {{ vals.DirectoryIndex }}{% endif %}
  32. {% if site.get('UseCanonicalName') %}UseCanonicalName {{ vals.UseCanonicalName }}{% endif %}
  33. {% if site.get('LogLevel') != False %}LogLevel {{ vals.LogLevel }}{% endif %}
  34. {% if site.get('ErrorLog') != False %}ErrorLog {{ vals.ErrorLog }}{% endif %}
  35. {% if site.get('CustomLog') != False %}CustomLog {{ vals.CustomLog }} {{ vals.LogFormat }}{% endif %}
  36. {% if site.get('DocumentRoot') != False %}DocumentRoot {{ vals.DocumentRoot }}{% endif %}
  37. {% if site.get('VirtualDocumentRoot') %}VirtualDocumentRoot {{ vals.VirtualDocumentRoot }}{% endif %}
  38. {% for path, dir in site.get('Directory', {}).items() %}
  39. {% set dvals = {
  40. 'Options': dir.get('Options', vals.Directory.Options),
  41. 'Order': dir.get('Order', vals.Directory.Order),
  42. 'Allow': dir.get('Allow', vals.Directory.Allow),
  43. 'Require': dir.get('Require', vals.Directory.Require),
  44. 'AllowOverride': dir.get('AllowOverride', vals.Directory.AllowOverride),
  45. } %}
  46. {% if path == 'default' %}{% set path = vals.Directory_default %}{% endif %}
  47. <Directory "{{ path }}">
  48. {% if dir.get('Options') != False %}Options {{ dvals.Options }}{% endif %}
  49. {% if apache.use_require %}
  50. {% if dir.get('Require') != False %}Require {{dvals.Require}}{% endif %}
  51. {% else %}
  52. {% if dir.get('Order') != False %}Order {{ dvals.Order }}{% endif %}
  53. {% if dir.get('Allow') != False %}Allow {{ dvals.Allow }}{% endif %}
  54. {% endif %}
  55. {% if dir.get('AllowOverride') != False %}AllowOverride {{ dvals.AllowOverride }}{% endif %}
  56. {% if dir.get('Formula_Append') %}
  57. {{ dir.Formula_Append|indent(8) }}
  58. {% endif %}
  59. </Directory>
  60. {% endfor %}
  61. {% if site.get('Formula_Append') %}
  62. {{ site.Formula_Append|indent(4) }}
  63. {% endif %}
  64. </VirtualHost>