Przeglądaj źródła

fix(vhosts): reset `cleanup` to previous and use dedicated `clean` SLS

tags/v1.2.1
Imran Iqbal 3 lat temu
rodzic
commit
0c6c1d36e2
Brak konta powiązanego z adresem e-mail autora
3 zmienionych plików z 46 dodań i 5 usunięć
  1. +0
    -1
      apache/config/vhosts/clean.sls
  2. +41
    -0
      apache/config/vhosts/clean.sls
  3. +5
    -4
      apache/config/vhosts/cleanup.sls

+ 0
- 1
apache/config/vhosts/clean.sls Wyświetl plik

@@ -1 +0,0 @@
cleanup.sls

+ 41
- 0
apache/config/vhosts/clean.sls Wyświetl plik

@@ -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 #}

+ 5
- 4
apache/config/vhosts/cleanup.sls Wyświetl plik

@@ -2,13 +2,13 @@
# vim: ft=sls

{%- 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 %}

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

include:
- {{ sls_service_clean }}
- {{ sls_service_running }}

{%- set dirpath = '/etc/apache2/sites-enabled' %}
{# Add . and .. to make it easier to not clean those #}
@@ -32,8 +32,9 @@ apache-config-vhosts-cleanup-{{ filename }}-cmd-run:
cmd.run:
- name: a2dissite {{ filename }} || true
- onlyif: "test -L {{ dirpath }}/{{ filename }} || test -f {{ dirpath }}/{{ filename }}"
- require:
- sls: {{ sls_service_clean }}
- require_in:
- module: apache-service-running-restart
- module: apache-service-running-reload

{%- endif %}
{%- endfor %}

Ładowanie…
Anuluj
Zapisz