Skip to content

fix(check_vars): tolerate inventories without an alert_server group - #80

Open
joseg20 wants to merge 1 commit into
mainfrom
fix/check-vars-combined-topology
Open

fix(check_vars): tolerate inventories without an alert_server group#80
joseg20 wants to merge 1 commit into
mainfrom
fix/check-vars-combined-topology

Conversation

@joseg20

@joseg20 joseg20 commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Problem

On a combined deployment (traefik + mediamtx + platform + alert API on a single VM — the topology playbooks/deploy-combined.yml supports) the inventory has no alert_server group.

check_vars references it directly:

when:
  - inventory_hostname in groups["alert_server"]

With the group absent, that expression raises a Jinja error instead of evaluating to false, so every engine deploy aborts in check_vars. Because the task sets no_log: true, the output is censored:

TASK [check_vars : Check API variables. no_log=true] ***
fatal: [somehost]: FAILED! => {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result"}

which makes it quite hard to diagnose (it cost us a while before spotting the missing group). The same pattern in Verify that each group contains only one host fails for the same reason.

Fix

  • guard both group lookups with groups.get(name, [])
  • default('') the API-only vars (POSTGRES_*, prefix) so templating them on hosts where they are undefined doesn't fail either

The Annotation server task right above already used groups.get(...), so this only makes the API and single-host-assert tasks consistent with it.

Testing

Verified on a combined deployment: make deploy-one-engine SITE=<host> failed before the change and completes after it (ok=24 changed=4), with the API checks correctly skipped on engine hosts.

On a combined deployment (traefik + mediamtx + platform + alert API on a
single VM, as deploy-combined.yml supports) the inventory has no
'alert_server' group. Referencing groups["alert_server"] then raises a
Jinja error instead of evaluating to false, so every engine deploy aborts
in check_vars -- and because the task sets no_log: true the message is
censored, which makes it hard to diagnose.

- guard both group lookups with groups.get(name, [])
- default('') the API-only vars (POSTGRES_*, prefix) so templating them on
  hosts where they are undefined does not fail either

The Annotation-server task above already used groups.get(...), so this
just makes the API and single-host-assert tasks consistent with it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant