mirror of
https://github.com/saltstack-formulas/apache-formula.git
synced 2025-04-17 10:10:26 +00:00
fix(vhosts): reset cleanup
to previous and use dedicated clean
SLS
This commit is contained in:
parent
35e9990a9a
commit
0c6c1d36e2
2 changed files with 46 additions and 5 deletions
|
@ -1 +0,0 @@
|
||||||
cleanup.sls
|
|
41
apache/config/vhosts/clean.sls
Normal file
41
apache/config/vhosts/clean.sls
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
{%- set tplroot = tpldir.split('/')[0] %}
|
||||||
|
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
|
||||||
|
{%- from tplroot ~ "/map.jinja" import apache with context %}
|
||||||
|
|
||||||
|
{%- if grains.os_family == 'Debian' %}
|
||||||
|
|
||||||
|
include:
|
||||||
|
- {{ sls_service_clean }}
|
||||||
|
|
||||||
|
{%- 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', {}).items() %}
|
||||||
|
{%- do valid_sites.append('{}{}'.format(site.name, apache.confext)) %}
|
||||||
|
{%- endfor %}
|
||||||
|
|
||||||
|
{%- if salt['file.directory_exists'](dirpath) %}
|
||||||
|
{%- for filename in salt['file.readdir'](dirpath) %}
|
||||||
|
{%- if filename not in valid_sites %}
|
||||||
|
|
||||||
|
apache-config-vhosts-clean-{{ filename }}-cmd-run:
|
||||||
|
cmd.run:
|
||||||
|
- name: a2dissite {{ filename }} || true
|
||||||
|
- onlyif: "test -L {{ dirpath }}/{{ filename }} || test -f {{ dirpath }}/{{ filename }}"
|
||||||
|
- require:
|
||||||
|
- sls: {{ sls_service_clean }}
|
||||||
|
|
||||||
|
{%- endif %}
|
||||||
|
{%- endfor %}
|
||||||
|
{%- endif %}
|
||||||
|
{%- endif %}{# Debian #}
|
|
@ -2,13 +2,13 @@
|
||||||
# vim: ft=sls
|
# vim: ft=sls
|
||||||
|
|
||||||
{%- set tplroot = tpldir.split('/')[0] %}
|
{%- set tplroot = tpldir.split('/')[0] %}
|
||||||
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
|
{%- set sls_service_running = tplroot ~ '.service.running' %}
|
||||||
{%- from tplroot ~ "/map.jinja" import apache with context %}
|
{%- from tplroot ~ "/map.jinja" import apache with context %}
|
||||||
|
|
||||||
{%- if grains.os_family == 'Debian' %}
|
{%- if grains.os_family == 'Debian' %}
|
||||||
|
|
||||||
include:
|
include:
|
||||||
- {{ sls_service_clean }}
|
- {{ sls_service_running }}
|
||||||
|
|
||||||
{%- set dirpath = '/etc/apache2/sites-enabled' %}
|
{%- set dirpath = '/etc/apache2/sites-enabled' %}
|
||||||
{# Add . and .. to make it easier to not clean those #}
|
{# Add . and .. to make it easier to not clean those #}
|
||||||
|
@ -32,8 +32,9 @@ apache-config-vhosts-cleanup-{{ filename }}-cmd-run:
|
||||||
cmd.run:
|
cmd.run:
|
||||||
- name: a2dissite {{ filename }} || true
|
- name: a2dissite {{ filename }} || true
|
||||||
- onlyif: "test -L {{ dirpath }}/{{ filename }} || test -f {{ dirpath }}/{{ filename }}"
|
- onlyif: "test -L {{ dirpath }}/{{ filename }} || test -f {{ dirpath }}/{{ filename }}"
|
||||||
- require:
|
- require_in:
|
||||||
- sls: {{ sls_service_clean }}
|
- module: apache-service-running-restart
|
||||||
|
- module: apache-service-running-reload
|
||||||
|
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
Loading…
Add table
Reference in a new issue