refactor(healthcheck): support multiple profiles per host with aggregate result

Replace the single healthcheck_profile with a healthcheck_profiles list so a
host can run several checks (e.g. hk2: pdns, rustdesk, hk2aux). Profiles emit
per-check JSON to latest-<check>.json; the dispatcher clears stale per-check
files, runs every profile, and merges them into latest.json.

Contract: a single complete check keeps the historical verbatim latest.json
shape; several checks produce a worst-status aggregate retaining every check's
detail. A profile that crashes before reporting is aggregated as unknown so
latest.json can never go stale while the dispatcher fails. The dispatcher exits
with the worst (max) profile exit code.
This commit is contained in:
windyboy
2026-08-12 21:16:30 +08:00
parent baca89be83
commit d0d5e5a704
4 changed files with 105 additions and 13 deletions
+8 -6
View File
@@ -1,9 +1,10 @@
---
- name: Validate known health-check profile
- name: Validate known health-check profiles
ansible.builtin.assert:
that:
- healthcheck_profile in healthcheck_profiles
fail_msg: "Unsupported healthcheck_profile: {{ healthcheck_profile }}"
- item in healthcheck_profile_scripts
fail_msg: "Unsupported healthcheck_profile: {{ item }}"
loop: "{{ healthcheck_profiles }}"
- name: Install health-check directories
ansible.builtin.file:
@@ -28,13 +29,14 @@
group: root
mode: "0755"
- name: Install service health-check script
- name: Install service health-check scripts
ansible.builtin.template:
src: "{{ healthcheck_profiles[healthcheck_profile] }}.j2"
dest: "{{ healthcheck_install_root }}/{{ healthcheck_profiles[healthcheck_profile] }}"
src: "{{ healthcheck_profile_scripts[item] }}.j2"
dest: "{{ healthcheck_install_root }}/{{ healthcheck_profile_scripts[item] }}"
owner: root
group: root
mode: "0755"
loop: "{{ healthcheck_profiles }}"
- name: Install health-check dispatcher
ansible.builtin.template: