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.

42 lines
1.1KB

  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. - require_in:
  24. - module: apache-restart
  25. - module: apache-reload
  26. - service: apache
  27. {% endif %}
  28. {% endfor %}
  29. {% endif %}{# Debian #}