From 9d3e62c3ccfe94dbfb763a8c64ffefb3cae8bb82 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Tue, 14 Sep 2021 20:54:31 +0100 Subject: [PATCH] all the fixes for `clean` states to work properly --- apache/config/certificates/clean.sls | 30 +++++++++------------------- apache/config/clean.sls | 2 ++ apache/config/modules/clean.sls | 8 +++----- apache/config/vhosts/cleanup.sls | 9 ++++----- 4 files changed, 18 insertions(+), 31 deletions(-) diff --git a/apache/config/certificates/clean.sls b/apache/config/certificates/clean.sls index e42c450..59f4c34 100644 --- a/apache/config/certificates/clean.sls +++ b/apache/config/certificates/clean.sls @@ -2,11 +2,11 @@ # vim: ft=sls {%- set tplroot = tpldir.split('/')[0] %} -{%- set sls_service_running = tplroot ~ '.service.running' %} +{%- set sls_service_clean = tplroot ~ '.service.clean' %} {%- from tplroot ~ "/map.jinja" import apache with context %} include: - - {{ sls_service_running }} + - {{ sls_service_clean }} {%- for site, cert in salt['pillar.get']('apache:sites', {}).items() %} @@ -15,12 +15,8 @@ include: apache_cert_config_clean_{{ site }}_key_file: file.absent: - name: {{ cert.SSLCertificateKeyFile }} - - watch_in: - - module: apache-service-running-reload - - require_in: - - module: apache-service-running-restart - - module: apache-service-running-reload - - service: apache-service-running + - require: + - sls: {{ sls_service_clean }} {%- endif %} {%- if cert.SSLCertificateFile is defined %} @@ -28,25 +24,17 @@ apache_cert_config_clean_{{ site }}_key_file: apache_cert_config_clean_{{ site }}_cert_file: file.absent: - name: {{ cert.SSLCertificateFile }} - - watch_in: - - module: apache-service-running-reload - - require_in: - - module: apache-service-running-restart - - module: apache-service-running-reload - - service: apache-service-running + - require: + - sls: {{ sls_service_clean }} {%- endif %} {%- if cert.SSLCertificateChainFile is defined %} apache_cert_config_clean_{{ site }}_bundle_file: - file.managed: + file.absent: - name: {{ cert.SSLCertificateChainFile }} - - watch_in: - - module: apache-service-running-reload - - require_in: - - module: apache-service-running-restart - - module: apache-service-running-reload - - service: apache-service-running + - require: + - sls: {{ sls_service_clean }} {%- endif %} {%- endfor %} diff --git a/apache/config/clean.sls b/apache/config/clean.sls index 7acf881..c335fba 100644 --- a/apache/config/clean.sls +++ b/apache/config/clean.sls @@ -3,6 +3,7 @@ {%- set tplroot = tpldir.split('/')[0] %} {%- set sls_service_clean = tplroot ~ '.service.clean' %} +{%- set sls_modules_clean = tplroot ~ '.config.modules.clean' %} {%- from tplroot ~ "/map.jinja" import apache with context %} include: @@ -21,3 +22,4 @@ apache-config-clean-file-absent: - {{ apache.confdir }}/server-status{{ apache.confext }} - require: - sls: {{ sls_service_clean }} + - sls: {{ sls_modules_clean }} diff --git a/apache/config/modules/clean.sls b/apache/config/modules/clean.sls index 057f363..9d1ab06 100644 --- a/apache/config/modules/clean.sls +++ b/apache/config/modules/clean.sls @@ -3,11 +3,11 @@ {%- set tplroot = tpldir.split('/')[0] %} {%- set sls_package_clean = tplroot ~ '.package.clean' %} -{%- set sls_service_dead = tplroot ~ '.service.clean' %} +{%- set sls_service_clean = tplroot ~ '.service.clean' %} {%- from tplroot ~ "/map.jinja" import apache with context %} include: - - {{ sls_service_dead }} + - {{ sls_service_clean }} {%- set existing_states = salt['cp.list_states']() %} {%- for module in salt['pillar.get']('apache:modules:disabled', []) %} @@ -45,8 +45,6 @@ apache-config-modules-{{ module }}-disable: - order: 225 - require: - - sls: {{ sls_service_dead }} - - require_in: - - pkg: apache-package-clean-pkg-removed + - sls: {{ sls_service_clean }} {%- endfor %} diff --git a/apache/config/vhosts/cleanup.sls b/apache/config/vhosts/cleanup.sls index a964dd8..f0b13da 100644 --- a/apache/config/vhosts/cleanup.sls +++ b/apache/config/vhosts/cleanup.sls @@ -2,13 +2,13 @@ # vim: ft=sls {%- set tplroot = tpldir.split('/')[0] %} -{%- set sls_service_running = tplroot ~ '.service.running' %} +{%- set sls_service_clean = tplroot ~ '.service.clean' %} {%- from tplroot ~ "/map.jinja" import apache with context %} {%- if grains.os_family == 'Debian' %} include: - - {{ sls_service_running }} + - {{ sls_service_clean }} {%- set dirpath = '/etc/apache2/sites-enabled' %} {# Add . and .. to make it easier to not clean those #} @@ -32,9 +32,8 @@ apache-config-vhosts-cleanup-{{ filename }}-cmd-run: cmd.run: - name: a2dissite {{ filename }} || true - onlyif: "test -L {{ dirpath }}/{{ filename }} || test -f {{ dirpath }}/{{ filename }}" - - require_in: - - module: apache-service-running-restart - - module: apache-service-running-reload + - require: + - sls: {{ sls_service_clean }} {%- endif %} {%- endfor %}