From 84433d5cbca8fd2421575674c6e1e9caddad9e71 Mon Sep 17 00:00:00 2001 From: Justin Date: Tue, 17 Nov 2026 15:38:08 -0600 Subject: [PATCH] Beszel: fail on silent update failures and crashed agents - Windows: fail if a scoop update ran but the agent version didn't change - Ubuntu: after restarting an upgraded agent, check it is still active Co-Authored-By: Claude Opus 5.5 --- ubuntu/update-beszel.yaml | 15 +++++++++++++++ windows/update-beszel.yaml | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/ubuntu/update-beszel.yaml b/ubuntu/update-beszel.yaml index a7b0015..abbe684 100644 --- a/ubuntu/update-beszel.yaml +++ b/ubuntu/update-beszel.yaml @@ -59,6 +59,21 @@ state: restarted when: before.stdout != after.stdout + # systemd reports success as soon as the process starts; make sure the new + # version didn't crash right after. + - name: Verify beszel-agent stayed running + when: before.stdout != after.stdout + block: + - name: Give the agent time to start + ansible.builtin.wait_for: + timeout: 10 + + - name: Check beszel-agent is active + ansible.builtin.command: systemctl is-active beszel-agent + register: agent_active + changed_when: false + failed_when: agent_active.stdout != 'active' + - name: Report ansible.builtin.debug: msg: "{{ before.stdout }} -> {{ after.stdout }}" diff --git a/windows/update-beszel.yaml b/windows/update-beszel.yaml index 4e91a34..a7fcc6c 100644 --- a/windows/update-beszel.yaml +++ b/windows/update-beszel.yaml @@ -48,6 +48,11 @@ ansible.windows.win_command: '"{{ agent_exe }}" -v' register: after changed_when: before.stdout != after.stdout + # scoop's exit code is lost through Out-String, so a failed update would otherwise + # look like success. If an update was attempted, the version must have changed. + failed_when: >- + after.rc != 0 or + (upd is not skipped and before.stdout | trim == after.stdout | trim) - name: Report ansible.builtin.debug: