all the fixes for clean states to work properly

This commit is contained in:
Imran Iqbal 2021-09-14 20:54:31 +01:00
parent c4dce07476
commit 9d3e62c3cc
No known key found for this signature in database
GPG Key ID: 6D8629439D2B7819
4 changed files with 18 additions and 31 deletions

View File

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

View File

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

View File

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

View File

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