Saltstack Official Apache Formula
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

43 行
1.5KB

  1. # -*- coding: utf-8 -*-
  2. # vim: ft=sls
  3. {%- set tplroot = tpldir.split('/')[0] %}
  4. {%- set sls_service_running = tplroot ~ '.service.running' %}
  5. {%- from tplroot ~ "/map.jinja" import apache with context %}
  6. {%- if grains.os_family == 'Debian' %}
  7. include:
  8. - {{ sls_service_running }}
  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_in:
  28. - module: apache-service-running-restart
  29. - module: apache-service-running-reload
  30. {%- endif %}
  31. {%- endfor %}
  32. {%- endif %}
  33. {%- endif %}{# Debian #}