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.

46 lines
1.5KB

  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. {%- set listen_directive = interface ~ ':' ~ port %}
  10. {%- if listen_directive not in listen_directives %}
  11. {%- do listen_directives.append(listen_directive) %}
  12. {%- endif %}
  13. {%- endfor %}
  14. {%- endfor %}
  15. {%- for listen in listen_directives %}
  16. Listen {{ listen }}
  17. {%- endfor %}
  18. {%- else %}
  19. Listen 80
  20. <IfModule mod_ssl.c>
  21. Listen 443
  22. </IfModule>
  23. <IfModule mod_gnutls.c>
  24. Listen 443
  25. </IfModule>
  26. {%- endif %}
  27. {%- if salt['pillar.get']('apache:name_virtual_hosts') is iterable %}
  28. {%- set name_virtual_host_directives = [] %}
  29. {%- for name_virtual_host in salt['pillar.get']('apache:name_virtual_hosts') %}
  30. {%- set interface = name_virtual_host.get('interface', '*') %}
  31. {%- set port = name_virtual_host.get('port', 80) %}
  32. {%- set name_virtual_host_directive = interface ~ ':' ~ port %}
  33. {%- do name_virtual_host_directives.append(name_virtual_host_directive) %}
  34. {%- endfor %}
  35. {%- for name_virtual_host in name_virtual_host_directives %}
  36. NameVirtualHost {{ name_virtual_host }}
  37. {%- endfor %}
  38. {%- endif -%}