Skip to content

feat(sensor): check hourly that fenrir is still an appliance - #1580

Merged
Gerrrt merged 3 commits into
mainfrom
feat/fenrir-appliance-check
Nov 19, 2026
Merged

Gerrrt merged 3 commits into
mainfrom
feat/fenrir-appliance-check

Conversation

@Gerrrt

@Gerrrt Gerrrt commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

What changed

fenrir now checks hourly that it is still the appliance build-the-sensor-guest.md leaves. scripts/collect-appliance-state.sh runs as root under a hardened unit and writes one 0-or-1 per check to appliance-state.prom, eleven in all:

  • sshd settings, the authorized keys, root's keys and sudoers.d
  • login accounts, atreus's groups, user units and linger
  • snaps, apt sources, host-namespace listeners, and the size of $HOME

Two lab rules read it, with promtool tests: ApplianceCheckFailed, a check failed on two hourly runs (for: 75m, past a single run's jitter), and ApplianceStateStopped, fenrir's series absent or the file stale for three hours, for as long as that lasts. The runbook gains the install step, and security.md's row says what this does and does not catch.

Why

The 2026-11-13 audit found fenrir used as a workstation for weeks with nothing saying so, and security.md said "Nothing re-checks this". This was the audit's last open next step.

Closes #1577.

Blast radius

fenrir only: the installer row requires /srv/sensor-data. The collector only reads; its one write is the textfile directory. If an allowlist is wrong, the cost is a false ApplianceCheckFailed in the lab, which pages no one (ADR-0020).

  • No change to network segmentation or firewall rules
  • No new port published to a VLAN that could not already reach the service
  • No credential added outside secrets/*.sops.yaml

Verification

  • collect-appliance-state.sh --self-test: 41 of 41 fixtures pass, run through self-tests.sh discovery. fenrir's live ss -H -lntu passes listeners_ok, and the same output plus a 127.0.0.1:3000 listener fails it.

  • promtool test rules lab.test.yaml: SUCCESS, with a firing and a quiet case for each rule, including the stale-file branch.

  • check_docs.py passes, with the lab rule count going from 23 to 25. shellcheck passes.

  • lint.sh matches main on this Mac: ansible-lint FAILs from the Mac runner, and markdownlint-cli2, zizmor, packer, tofu and editorconfig-checker SKIP for lack of a docker daemon. Those are left to CI.

  • Of the other self-test suites, 15 fail on this Mac, and the same 15 fail on main.

  • On fenrir: make install-agent-collectors AGENT=atreus@10.0.30.90 ARGS='--only appliance-state' passed and wrote 11 samples. The first run logged all 11 checks pass, and the lab's Prometheus received the 11 series under job="fenrir-metrics".

  • A failure on purpose: a throwaway public key, with its private half deleted, was appended to authorized_keys. The 05:01 UTC run logged FAILED: keys, and the lab's Prometheus read keys as 0. The key was then removed, and the 06:01 run will read 1 again.

  • After review (cacc5e6): root's keys, user units in all three load paths, and apt origins rather than filenames. The new apt and /etc/systemd/user parsers pass on fenrir's live files. With the old for: 1h put back, the new boundary tests fail at 3h10m and 3h15m.

  • Not yet: fenrir runs the pre-review collector until install-agent-collectors --only appliance-state is re-run after merge, and the rules are not loaded on alexander until make up STACK=lab runs there.

  • make validate passes (not run in full on the Mac; see above)

  • Deployed to the lab and confirmed working

  • Docs updated (docs/, service README, or docs/roadmap.md)

🤖 Generated with Claude Code

Gerrrt and others added 2 commits November 18, 2026 21:02
A collector on fenrir reads what build-the-sensor-guest.md leaves (sshd,
the keys, root's keys, sudoers.d, login accounts, groups, user units and
linger, snaps, apt sources, host listeners, the size of $HOME) and writes
one 0-or-1 per check. ApplianceCheckFailed and ApplianceStateStopped read
it in the lab. It catches drift by accident only: root on fenrir can make
it read clean, and the collector's header and security.md say so.

Refs #1577

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #1577

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 05:03
@Gerrrt
Gerrrt enabled auto-merge (squash) November 19, 2026 05:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Collector validation gaps can falsely report compliance, while alert timing and missing-series handling can cause premature firing or clearing without recovery.

5 open issues
What changed in this PR

Adds hourly appliance-drift monitoring for fenrir, using the existing agent-collector and lab Prometheus infrastructure to detect departures from the sensor runbook.

Changes:

  • Adds eleven pass/fail checks, a hardened systemd service and timer, and installer integration.
  • Adds lab alerts and rule tests for failed checks and stopped reporting.
  • Documents installation, monitoring coverage, and limitations: guest root can falsify results, and lab alerts page no one.
File Description
systemd/​README.md Lists the new appliance-check timer.
systemd/​agent/​homelab-appliance-state.timer Schedules hourly and post-boot checks.
systemd/​agent/​homelab-appliance-state.service Runs the collector with restricted write access.
stacks/​lab/​README.md Updates the lab alert inventory.
stacks/​lab/​prometheus/​tests/​lab.test.yaml Tests failed checks and missing or stale reporting.
stacks/​lab/​prometheus/​rules/​lab.rules.yaml Adds appliance failure and reporting alerts.
scripts/​README.md Documents the new collector.
scripts/​install-agent-collectors.sh Registers the sensor-specific installer row.
scripts/​collect-appliance-state.sh Implements eleven checks and parser fixtures.
docs/​security.md Describes drift monitoring and its trust limitations.
docs/​runbooks/​schedule-maintenance.md Adds appliance monitoring to the collector inventory.
docs/​runbooks/​build-the-sensor-guest.md Adds fingerprint setup and installation instructions.
docs/​changelog.md Records implementation and deployment evidence.

Review effort: Balanced

Comment thread scripts/collect-appliance-state.sh Resolved
Comment thread scripts/collect-appliance-state.sh Resolved
Comment thread scripts/collect-appliance-state.sh Resolved
- The Lint failure: a diff3 base marker left in the changelog by the rebase.
- root's keys: an indented key is a key, and a read error no longer passes.
- User units: ~/.local/share/systemd/user and /etc/systemd/user count too,
  the second against 26.04's baseline as measured on fenrir.
- apt: every URI in each .list and .sources file must be an allowed origin,
  not only the filenames.
- ApplianceCheckFailed holds 75m, past a single run's jitter, with tests at
  the boundary that fail against the old 1h.
- ApplianceStateStopped reads fenrir's absence directly, so it no longer
  clears itself a day after the collector stops.

Refs #1577

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gerrrt
Gerrrt merged commit 6b9acbe into main Nov 19, 2026
10 checks passed
@Gerrrt
Gerrrt deleted the feat/fenrir-appliance-check branch November 19, 2026 05:32
Gerrrt added a commit that referenced this pull request Nov 19, 2026
…1585)

* fix(alerts): stopped-collector rules hold for two weeks, not a day

PatchStateStopped (estate and lab) and GuestStateStopped looked back
[1d] offset 6h, so about 30 h after the last sample the "was reporting"
side emptied and the alert resolved with nothing recovered. They now
look back 14 days, inside both Prometheuses' retention. New promtool
cases fire at 3 d and 10 d and are quiet at 16 d; with [1d] put back
the 3 d and 10 d cases fail.

The sensor runbook's sshd step also removes cloud-init's
50-cloud-init.conf, now removed on fenrir. The changelog records both,
and that alexander's pending security updates are Ubuntu's phasing.

Refs #1580

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(alerts): say what the 14-day stopped rules cannot see

Review on #1585:
- The estate's PatchStateStopped and GuestStateStopped see a series
  vanish, not a timer that stops and leaves its .prom file, which is
  re-served on every scrape. The rule comments and changelog now say
  so; the lab's copy has an mtime branch, the estate's do not yet.
- The lab has no Alertmanager (ADR-0020), so its rule comment no
  longer says to silence a retired guest.
- GuestStateStopped's long-gap test now also asserts quiet at 16 d.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

Check that fenrir stays an appliance

2 participants