Saltstack Official Apache Formula
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

42 líneas
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 #}