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 # vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %} {%- 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 %} {%- from tplroot ~ "/map.jinja" import apache with context %}
include: include:
- {{ sls_service_running }} - {{ sls_service_clean }}
{%- for site, cert in salt['pillar.get']('apache:sites', {}).items() %} {%- for site, cert in salt['pillar.get']('apache:sites', {}).items() %}
@ -15,12 +15,8 @@ include:
apache_cert_config_clean_{{ site }}_key_file: apache_cert_config_clean_{{ site }}_key_file:
file.absent: file.absent:
- name: {{ cert.SSLCertificateKeyFile }} - name: {{ cert.SSLCertificateKeyFile }}
- watch_in: - require:
- module: apache-service-running-reload - sls: {{ sls_service_clean }}
- require_in:
- module: apache-service-running-restart
- module: apache-service-running-reload
- service: apache-service-running
{%- endif %} {%- endif %}
{%- if cert.SSLCertificateFile is defined %} {%- if cert.SSLCertificateFile is defined %}
@ -28,25 +24,17 @@ apache_cert_config_clean_{{ site }}_key_file:
apache_cert_config_clean_{{ site }}_cert_file: apache_cert_config_clean_{{ site }}_cert_file:
file.absent: file.absent:
- name: {{ cert.SSLCertificateFile }} - name: {{ cert.SSLCertificateFile }}
- watch_in: - require:
- module: apache-service-running-reload - sls: {{ sls_service_clean }}
- require_in:
- module: apache-service-running-restart
- module: apache-service-running-reload
- service: apache-service-running
{%- endif %} {%- endif %}
{%- if cert.SSLCertificateChainFile is defined %} {%- if cert.SSLCertificateChainFile is defined %}
apache_cert_config_clean_{{ site }}_bundle_file: apache_cert_config_clean_{{ site }}_bundle_file:
file.managed: file.absent:
- name: {{ cert.SSLCertificateChainFile }} - name: {{ cert.SSLCertificateChainFile }}
- watch_in: - require:
- module: apache-service-running-reload - sls: {{ sls_service_clean }}
- require_in:
- module: apache-service-running-restart
- module: apache-service-running-reload
- service: apache-service-running
{%- endif %} {%- endif %}
{%- endfor %} {%- endfor %}

View File

@ -3,6 +3,7 @@
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_service_clean = tplroot ~ '.service.clean' %} {%- set sls_service_clean = tplroot ~ '.service.clean' %}
{%- set sls_modules_clean = tplroot ~ '.config.modules.clean' %}
{%- from tplroot ~ "/map.jinja" import apache with context %} {%- from tplroot ~ "/map.jinja" import apache with context %}
include: include:
@ -21,3 +22,4 @@ apache-config-clean-file-absent:
- {{ apache.confdir }}/server-status{{ apache.confext }} - {{ apache.confdir }}/server-status{{ apache.confext }}
- require: - require:
- sls: {{ sls_service_clean }} - sls: {{ sls_service_clean }}
- sls: {{ sls_modules_clean }}

View File

@ -3,11 +3,11 @@
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- set sls_package_clean = tplroot ~ '.package.clean' %} {%- 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 %} {%- from tplroot ~ "/map.jinja" import apache with context %}
include: include:
- {{ sls_service_dead }} - {{ sls_service_clean }}
{%- set existing_states = salt['cp.list_states']() %} {%- set existing_states = salt['cp.list_states']() %}
{%- for module in salt['pillar.get']('apache:modules:disabled', []) %} {%- for module in salt['pillar.get']('apache:modules:disabled', []) %}
@ -45,8 +45,6 @@ apache-config-modules-{{ module }}-disable:
- order: 225 - order: 225
- require: - require:
- sls: {{ sls_service_dead }} - sls: {{ sls_service_clean }}
- require_in:
- pkg: apache-package-clean-pkg-removed
{%- endfor %} {%- endfor %}

View File

@ -2,13 +2,13 @@
# vim: ft=sls # vim: ft=sls
{%- set tplroot = tpldir.split('/')[0] %} {%- 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 %} {%- from tplroot ~ "/map.jinja" import apache with context %}
{%- if grains.os_family == 'Debian' %} {%- if grains.os_family == 'Debian' %}
include: include:
- {{ sls_service_running }} - {{ sls_service_clean }}
{%- 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,9 +32,8 @@ 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_in: - require:
- module: apache-service-running-restart - sls: {{ sls_service_clean }}
- module: apache-service-running-reload
{%- endif %} {%- endif %}
{%- endfor %} {%- endfor %}