Browse Source

Merge pull request #372 from myii/fix/reset-vhosts-cleanup-and-provide-separate-clean

fix(vhosts): reset `cleanup` to previous and use dedicated `clean` SLS
tags/v1.2.1
Imran Iqbal 3 years ago
parent
commit
ce4f4a72c3
No account linked to committer's email address
3 changed files with 46 additions and 5 deletions
  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 View File

cleanup.sls

+ 41
- 0
apache/config/vhosts/clean.sls View File

# -*- 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 View File

# 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 #}
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:
- sls: {{ sls_service_clean }}
- require_in:
- module: apache-service-running-restart
- module: apache-service-running-reload


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

Loading…
Cancel
Save