浏览代码

Merge pull request #232 from ze42/vhosts_cleanup

vhosts/cleanup: clean non-salted sites
master
Niels Abspoel 6 年前
父节点
当前提交
00b437aa27
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 37 次插入0 次删除
  1. +37
    -0
      apache/vhosts/cleanup.sls

+ 37
- 0
apache/vhosts/cleanup.sls 查看文件

@@ -0,0 +1,37 @@
{% from "apache/map.jinja" import apache with context %}

include:
- apache

{% if grains.os_family == 'Debian' %}

{% set dirpath = '/etc/apache2/sites-enabled' %}

{# Add . and .. to make it easier to not clean those #}
{% set valid_sites = ['.', '..', ] %}

{# Take sites from apache.vhosts.standard #}
{% for id, site in salt['pillar.get']('apache:sites', {}).items() %}
{% do valid_sites.append('{}{}'.format(id, apache.confext)) %}
{% endfor %}

{# Take sites from apache.register_site #}
{% for id, site in salt['pillar.get']('apache:register-site', {}) %}
{% do valid_sites.append('{}{}'.format(site.name, apache.confext)) %}
{% endfor %}


{% for filename in salt['file.readdir']('/etc/apache2/sites-enabled/') %}
{% if filename not in valid_sites %}

a2dissite {{ filename }}:
cmd.run:
- onlyif: "test -L {{ dirpath}}/{{ filename }} || test -f {{ dirpath}}/{{ filename }}"
- watch_in:
- module: apache-reload

{% endif %}
{% endfor %}


{% endif %}{# Debian #}

正在加载...
取消
保存