Saltstack Official Apache Formula
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

42 lines
1.4KB

  1. # -*- coding: utf-8 -*-
  2. # vim: ft=sls
  3. {%- set tplroot = tpldir.split('/')[0] %}
  4. {%- set sls_service_clean = tplroot ~ '.service.clean' %}
  5. {%- from tplroot ~ "/map.jinja" import apache with context %}
  6. {%- if grains.os_family == 'Debian' %}
  7. include:
  8. - {{ sls_service_clean }}
  9. {%- set dirpath = '/etc/apache2/sites-enabled' %}
  10. {# Add . and .. to make it easier to not clean those #}
  11. {%- set valid_sites = ['.', '..', ] %}
  12. {# Take sites from apache.vhosts.standard #}
  13. {%- for id, site in salt['pillar.get']('apache:sites', {}).items() %}
  14. {%- do valid_sites.append('{}{}'.format(id, apache.confext)) %}
  15. {%- endfor %}
  16. {# Take sites from apache.register_site #}
  17. {%- for id, site in salt['pillar.get']('apache:register-site', {}).items() %}
  18. {%- do valid_sites.append('{}{}'.format(site.name, apache.confext)) %}
  19. {%- endfor %}
  20. {%- if salt['file.directory_exists'](dirpath) %}
  21. {%- for filename in salt['file.readdir'](dirpath) %}
  22. {%- if filename not in valid_sites %}
  23. apache-config-vhosts-cleanup-{{ filename }}-cmd-run:
  24. cmd.run:
  25. - name: a2dissite {{ filename }} || true
  26. - onlyif: "test -L {{ dirpath }}/{{ filename }} || test -f {{ dirpath }}/{{ filename }}"
  27. - require:
  28. - sls: {{ sls_service_clean }}
  29. {%- endif %}
  30. {%- endfor %}
  31. {%- endif %}
  32. {%- endif %}{# Debian #}