Auto-detect conditional restart based on playbook tags and add CHANGELOG entry

- Override devture_systemd_service_manager_conditional_restart_enabled in
  group_vars based on ansible_run_tags: disabled when setup-* tags are used,
  enabled otherwise. This replaces the --extra-vars hack in the justfile and
  ensures consistent behavior for both `just` and raw `ansible-playbook` users.
- Revert justfile setup-all to its original form (no --extra-vars needed).
- Update docs/just.md to reflect tag-agnostic behavior.
- Add CHANGELOG.md entry documenting the conditional restart feature.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Slavi Pantaleev
2026-02-13 14:21:07 +02:00
parent 3e73005eb3
commit 4a8df13854
4 changed files with 42 additions and 5 deletions

View File

@@ -1,3 +1,27 @@
# 2026-02-13
## Conditional service restart for `install-*` commands
When running `install-all` or `install-service` (whether via `just` or raw `ansible-playbook`), only services whose configuration or container image actually changed during the playbook run will now be restarted. Unchanged services are left running (or get started if they were stopped). This reduces unnecessary downtime — particularly for services like Traefik (the reverse proxy), which previously caused brief connectivity interruptions on every playbook run even when nothing changed.
When running with `setup-*` tags (e.g. `setup-all`, `setup-synapse`), all services continue to be unconditionally restarted as before.
Currently, only Traefik tracks its own changes and benefits from conditional restart. All other services default to being restarted (the previous behavior). This is just the beginning — as more roles gain change-tracking support, playbook performance will improve and downtime will decrease dramatically, especially for `install-all` runs where most services haven't changed.
Some benchmarks for `just install-service traefik` when Traefik settings did not change:
- **Before**:
- total time: ~56 seconds 🐌
- Traefik restarted: yes (unnecessarily) ❌
- dependent services restarted: yes, all of them ❌
- **After**:
- total time: ~27 seconds ⚡
- Traefik restarted: no ✅
- dependent services restarted: no ✅
This behavior can be overridden via `--extra-vars='devture_systemd_service_manager_conditional_restart_enabled=false'` to force unconditional restarts. See [Conditional service restart](docs/just.md#conditional-service-restart) for details.
# 2026-02-12
## Dimension integration manager has been removed from the playbook

View File

@@ -46,10 +46,10 @@ Such kind of difference sometimes matters. For example, when you install a Matri
## Conditional service restart
When using `just install-all` or `just install-service`, only services whose configuration or container image actually changed during the playbook run will be restarted. Unchanged services are left running (or get started if they were stopped). This reduces unnecessary downtime.
When running `install-all` or `install-service` (whether via `just` or raw `ansible-playbook`), only services whose configuration or container image actually changed during the playbook run will be restarted. Unchanged services are left running (or get started if they were stopped). This reduces unnecessary downtime.
When using `just setup-all`, all services are unconditionally restarted regardless of whether changes were detected. This is appropriate for `setup-all`'s thorough "full setup" semantics.
When running with `setup-*` tags (e.g. `setup-all`, `setup-synapse`), all services are unconditionally restarted regardless of whether changes were detected. This is appropriate for setup's thorough "full setup" semantics.
`just start-all` and `just start-group` always restart all targeted services, since no installation tasks run during these commands.
`start-all` and `start-group` always restart all targeted services, since no installation tasks run during these commands.
This behavior is controlled by the `devture_systemd_service_manager_conditional_restart_enabled` variable (default: `true`). To force unconditional restarts during installation, pass: `just install-all --extra-vars='devture_systemd_service_manager_conditional_restart_enabled=false'`
This behavior is automatically determined based on the playbook tags in use. It can be overridden with the `devture_systemd_service_manager_conditional_restart_enabled` variable. For example, to force unconditional restarts during installation: `just install-all --extra-vars='devture_systemd_service_manager_conditional_restart_enabled=false'`

View File

@@ -265,6 +265,19 @@ matrix_addons_homeserver_systemd_services_list: |
# - so that, when the reverse-proxy is up (Matrix is up), all bots and bridges can be interacted with
# - monitoring services (Prometheus, Grafana, …) get a level of 4000 — they can start later than all-of-Matrix
# - services which aren't time-sensitive (various crons and timers) get a level of 5000 — they can start later than all-of-Matrix
# The systemd_service_manager role supports conditional restart — only restarting services
# whose configuration or container image actually changed, leaving unchanged services running.
# This is controlled by `devture_systemd_service_manager_conditional_restart_enabled` (default: true in the role).
#
# We override it here to automatically match the intent of the playbook tags being used:
# - install-* tags (regular upgrades): conditional restart ON — only changed services restart, reducing downtime
# - setup-* tags (full setup/reconfiguration): conditional restart OFF — all services restart unconditionally
#
# This ensures consistent behavior whether users invoke the playbook via `just` shortcuts
# or raw `ansible-playbook --tags=...` commands.
devture_systemd_service_manager_conditional_restart_enabled: "{{ ansible_run_tags | select('match', 'setup-') | list | length == 0 }}"
devture_systemd_service_manager_services_list_auto: |
{{
([{

View File

@@ -53,7 +53,7 @@ install-service service *extra_args:
--extra-vars=group={{ service }} {{ extra_args }}
# Runs the playbook with --tags=setup-all,ensure-matrix-users-created,start and optional arguments
setup-all *extra_args: (run-tags "setup-all,ensure-matrix-users-created,start" "--extra-vars=devture_systemd_service_manager_conditional_restart_enabled=false" extra_args)
setup-all *extra_args: (run-tags "setup-all,ensure-matrix-users-created,start" extra_args)
# Runs the playbook with the given list of arguments
run +extra_args: