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.

38 lines
997B

  1. {% from "apache/map.jinja" import apache with context %}
  2. include:
  3. - apache
  4. {% if grains.os_family == 'Debian' %}
  5. {% set dirpath = '/etc/apache2/sites-enabled' %}
  6. {# Add . and .. to make it easier to not clean those #}
  7. {% set valid_sites = ['.', '..', ] %}
  8. {# Take sites from apache.vhosts.standard #}
  9. {% for id, site in salt['pillar.get']('apache:sites', {}).items() %}
  10. {% do valid_sites.append('{}{}'.format(id, apache.confext)) %}
  11. {% endfor %}
  12. {# Take sites from apache.register_site #}
  13. {% for id, site in salt['pillar.get']('apache:register-site', {}) %}
  14. {% do valid_sites.append('{}{}'.format(site.name, apache.confext)) %}
  15. {% endfor %}
  16. {% for filename in salt['file.readdir']('/etc/apache2/sites-enabled/') %}
  17. {% if filename not in valid_sites %}
  18. a2dissite {{ filename }}:
  19. cmd.run:
  20. - onlyif: "test -L {{ dirpath}}/{{ filename }} || test -f {{ dirpath}}/{{ filename }}"
  21. - watch_in:
  22. - module: apache-reload
  23. {% endif %}
  24. {% endfor %}
  25. {% endif %}{# Debian #}