Saltstack Official Apache Formula
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

cleanup.sls 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. {% if salt['file.directory_exists'](dirpath) %}
  17. {% for filename in salt['file.readdir'](dirpath) %}
  18. {% if filename not in valid_sites %}
  19. a2dissite {{ filename }}:
  20. cmd.run:
  21. - onlyif: "test -L {{ dirpath }}/{{ filename }} || test -f {{ dirpath }}/{{ filename }}"
  22. - watch_in:
  23. - module: apache-reload
  24. - require_in:
  25. - module: apache-restart
  26. - module: apache-reload
  27. - service: apache
  28. {% endif %}
  29. {% endfor %}
  30. {% endif %}
  31. {% endif %}{# Debian #}