mirror of
https://github.com/saltstack-formulas/apache-formula.git
synced 2025-04-17 10:10:26 +00:00
vhosts/cleanup: clean non-salted sites
Makes it easier to clean any unwanted sites
This commit is contained in:
parent
dc46bc8340
commit
fdaa62d7a9
1 changed files with 37 additions and 0 deletions
37
apache/vhosts/cleanup.sls
Normal file
37
apache/vhosts/cleanup.sls
Normal file
|
@ -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 #}
|
Loading…
Add table
Reference in a new issue