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.

48 lines
1.6KB

  1. {%- from "apache/map.jinja" import apache with context -%}
  2. # Managed by saltstack
  3. {% if salt['pillar.get']('apache:sites') is mapping %}
  4. {%- set listen_directives = [] %}
  5. {%- for id, site in salt['pillar.get']('apache:sites').items() %}
  6. {%- set interfaces = site.get('interface', '*').split() %}
  7. {%- set port = site.get('port', 80) %}
  8. {%- for interface in interfaces %}
  9. {%- if not site.get('exclude_listen_directive', False) %}
  10. {%- set listen_directive = interface ~ ':' ~ port %}
  11. {%- if listen_directive not in listen_directives %}
  12. {%- do listen_directives.append(listen_directive) %}
  13. {%- endif %}
  14. {%- endif %}
  15. {%- endfor %}
  16. {%- endfor %}
  17. {%- for listen in listen_directives %}
  18. Listen {{ listen }}
  19. {%- endfor %}
  20. {%- else %}
  21. Listen 80
  22. <IfModule mod_ssl.c>
  23. Listen 443
  24. </IfModule>
  25. <IfModule mod_gnutls.c>
  26. Listen 443
  27. </IfModule>
  28. {%- endif %}
  29. {%- if salt['pillar.get']('apache:name_virtual_hosts') is iterable %}
  30. {%- set name_virtual_host_directives = [] %}
  31. {%- for name_virtual_host in salt['pillar.get']('apache:name_virtual_hosts') %}
  32. {%- set interface = name_virtual_host.get('interface', '*') %}
  33. {%- set port = name_virtual_host.get('port', 80) %}
  34. {%- set name_virtual_host_directive = interface ~ ':' ~ port %}
  35. {%- do name_virtual_host_directives.append(name_virtual_host_directive) %}
  36. {%- endfor %}
  37. {%- for name_virtual_host in name_virtual_host_directives %}
  38. NameVirtualHost {{ name_virtual_host }}
  39. {%- endfor %}
  40. {%- endif -%}