From 5338e8cbdb4500c71833e682658a5eec5c4299eb Mon Sep 17 00:00:00 2001 From: Alexander Weidinger Date: Thu, 21 Mar 2024 22:45:22 +0100 Subject: [PATCH 1/3] fix(apache.service.running): prevent recursive requisite --- apache/config/file.sls | 16 +++++++--------- apache/service/running.sls | 12 ++---------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/apache/config/file.sls b/apache/config/file.sls index 2da8862c..9cc5c93c 100644 --- a/apache/config/file.sls +++ b/apache/config/file.sls @@ -19,7 +19,7 @@ apache-config-file-directory-logdir: - makedirs: True - require: - sls: {{ sls_package_install }} - - require_in: + - watch_in: - service: apache-service-running apache-config-file-directory-vhostdir: @@ -28,7 +28,7 @@ apache-config-file-directory-vhostdir: - makedirs: True - require: - sls: {{ sls_package_install }} - - require_in: + - watch_in: - service: apache-service-running apache-config-file-directory-moddir: @@ -37,7 +37,7 @@ apache-config-file-directory-moddir: - makedirs: True - require: - sls: {{ sls_package_install }} - - require_in: + - watch_in: - service: apache-service-running {%- if apache.davlockdbdir %} @@ -53,7 +53,7 @@ apache-config-file-directory-davlockdbdir: - group - require: - sls: {{ sls_package_install }} - - require_in: + - watch_in: - service: apache-service-running {%- endif %} @@ -65,7 +65,7 @@ apache-config-file-directory-sites-enabled: - makedirs: True - require: - sls: {{ sls_package_install }} - - require_in: + - watch_in: - service: apache-service-running {%- endif %} @@ -77,7 +77,7 @@ apache-config-file-directory-conf-enabled: - makedirs: True - require: - sls: {{ sls_package_install }} - - require_in: + - watch_in: - service: apache-service-running {%- endif %} @@ -111,7 +111,7 @@ apache-config-file-managed-{{ grains.os }}-env: - template: {{ apache.get('template_engine', 'jinja') }} - context: apache: {{ apache | json }} - - require_in: + - watch_in: - file: apache-config-file-managed-{{ grains.os }}-ports apache-config-file-managed-{{ grains.os }}-ports: @@ -158,6 +158,4 @@ apache-config-file-managed-skip: - sls: {{ sls_package_install }} - watch_in: - module: apache-service-running-restart - - require_in: - - module: apache-service-running-restart - service: apache-service-running diff --git a/apache/service/running.sls b/apache/service/running.sls index 07299777..fed21e7e 100644 --- a/apache/service/running.sls +++ b/apache/service/running.sls @@ -16,8 +16,6 @@ apache-service-running: service.running: - name: {{ apache.service.name }} - enable: True - - watch: - - sls: {{ sls_config_file }} - retry: {{ apache.retry_option|json }} cmd.run: - names: @@ -41,10 +39,7 @@ apache-service-running-restart: - cmd: {{ apache.custom_reload_command|default('apachectl graceful') }} - python_shell: True {%- endif %} - - watch: - - sls: {{ sls_config_file }} - - require: - - sls: {{ sls_config_file }} + - after: - service: apache-service-running apache-service-running-reload: @@ -57,8 +52,5 @@ apache-service-running-reload: - cmd: {{ apache.custom_reload_command|default('apachectl graceful') }} - python_shell: True {%- endif %} - - watch: - - sls: {{ sls_config_file }} - - require: - - sls: {{ sls_config_file }} + - after: - service: apache-service-running From 20654f31cd066a8d30b2e0d0eb0b5fd0727087d3 Mon Sep 17 00:00:00 2001 From: Alex Dehnert Date: Sun, 13 Jul 2025 04:22:48 +0000 Subject: [PATCH 2/3] fix(apache.service.running): More consistent amount of logging If Apache fails to start, on a non-systemd system, we dump 20 lines of logs, which seems like enough to give a good hint of what went wrong. When available, however, we instead use `journalctl -xe`. `journalctl -x` annotates each log message, resulting in a large amount of context for each line. `journalctl -e` implicitly allows a cap of 1000 lines of *log* to be printed, which is further multiplied by the annotations. IME the annotations aren't actually useful for Apache restarts (*Apache's* output doesn't have any, so it's just a lot of explanation of what systemd is doing). Rather than cluttering up Salt's output, this change makes `journalctl` consistent with non-systemd log dumping: 20 lines max, with no context. An admin can easily run `journalctl -xe` themselves if they actually need the annotations or more lines. --- apache/service/running.sls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apache/service/running.sls b/apache/service/running.sls index fed21e7e..bd4cf667 100644 --- a/apache/service/running.sls +++ b/apache/service/running.sls @@ -19,7 +19,7 @@ apache-service-running: - retry: {{ apache.retry_option|json }} cmd.run: - names: - - journalctl -xe -u {{ apache.service.name }} || tail -20 /var/log/messages || true + - journalctl -n20 -e -u {{ apache.service.name }} || tail -20 /var/log/messages || true - (service {{ apache.service.name }} restart && service {{ apache.service.name }} status) || true - cat {{ apache.config }} - onfail: From 3d8b560acc4680b108f3b6f2f31e45c817395064 Mon Sep 17 00:00:00 2001 From: Alex Dehnert Date: Sun, 13 Jul 2025 04:30:54 +0000 Subject: [PATCH 3/3] fix(apache.service.running): further improve circular requisites This is a follow-on to PR #388: - When the main Apache config file changes, reload Apache - Installing modules only needs the module dir to exist, it doesn't need the entire config. Tightening up this requisite avoids potential circular dependencies. --- apache/config/file.sls | 2 ++ apache/config/modules/install.sls | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/apache/config/file.sls b/apache/config/file.sls index 9cc5c93c..9db036a1 100644 --- a/apache/config/file.sls +++ b/apache/config/file.sls @@ -97,6 +97,8 @@ apache-config-file-managed: - sls: {{ sls_package_install }} - context: apache: {{ apache | json }} + - watch_in: + - service: apache-service-running {%- if grains.os_family in ('Debian', 'FreeBSD') %} diff --git a/apache/config/modules/install.sls b/apache/config/modules/install.sls index 9cc52730..b85c80c0 100644 --- a/apache/config/modules/install.sls +++ b/apache/config/modules/install.sls @@ -41,7 +41,7 @@ apache-config-modules-{{ module }}-enable: {%- endif %} - order: 225 - require: - - sls: {{ sls_config_file }} + - file: apache-config-file-directory-moddir - watch_in: - module: apache-service-running-restart - require_in: