Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ documents for different readers.
at all. Every pinned digest is also scanned weekly for fixable HIGH and
CRITICAL CVEs, and each image with findings has an open issue until a scan
finds it clean.
- **Documented decisions and runbooks.** 143 ADRs covering what was chosen
- **Documented decisions and runbooks.** 145 ADRs covering what was chosen
and what was rejected — including the costs accepted knowingly; 57
runbooks for the operations that are easy to get wrong at 1am, one of which
is the handover page a successor reads first. Every critical alert links to
Expand Down Expand Up @@ -236,7 +236,7 @@ inbound passes may still reach it. Data flow and the maintained Mermaid topology
│ ├── architecture.md network.md hardware.md
│ ├── observability.md security.md roadmap.md changelog.md
│ ├── diagrams/ # the network diagram (SVG) and its predecessors
│ ├── adr/ # 143 ADRs — architecture decision records
│ ├── adr/ # 145 ADRs — architecture decision records
│ ├── exercises/ # purple-team exercise records — see its README
│ └── runbooks/ # 57 runbooks; successor-handover.md is the front door
└── Makefile # make help
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ re-read [#485](https://github.com/Gerrrt/HomeLab/issues/485) asked for
> day; ADR-0027's sentence and `build-the-soc-guest.md`'s note become history
> with it. The verify job's outcome does not yet reach the lab's alerting,
> which is what keeps #485 open. Nothing here is amended, per ADR-0001.
>
> [!NOTE]
> Amended by [ADR-0143](0143-back-up-phoenix-for-its-opentofu-state.md):
> `phoenix` joins the nightly job, for the OpenTofu state that is in no
> repository. The sentence below that leaves it out is left as written.

## Context

Expand Down
84 changes: 84 additions & 0 deletions docs/adr/0143-back-up-phoenix-for-its-opentofu-state.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# ADR-0143: Back up `phoenix` nightly, for its OpenTofu state

**Status:** Accepted · 2026-11 · amends
[ADR-0053](0053-run-pbs-on-saruman-with-its-datastore-on-smaug-over-nfs.md)

## Context

[ADR-0053](0053-run-pbs-on-saruman-with-its-datastore-on-smaug-over-nfs.md)
backs up the Windows domain, `odin` and, since
[ADR-0091](0091-put-a-kali-purple-analyst-workstation-on-saruman.md),
`garuda`. It leaves out "`phoenix` or `golem` itself, which are rebuilt from
this repository". `build-the-backup-guest.md` §8 repeats that, and the job on
`Saruman` holds no `170`. The one backup of `phoenix` ever taken was §9's
proof, and §9 deletes it.

The recheck of `phoenix` on 2026-11-25 found that one file on it is not in
this repository and cannot be rebuilt from it: `tofu/state/lab.tfstate`.
[ADR-0076](0076-provision-lab-guests-with-opentofu-and-encrypt-its-state-from-the-first-apply.md)
encrypts it and keeps it out of git on purpose, and `.gitignore` and
`check-tracked-artefacts.sh` refuse it. The passphrase is escrowed in
`secrets/tofu.sops.yaml`, but the file the passphrase opens is not escrowed
anywhere. [`provision-lab-guests.md`](../runbooks/provision-lab-guests.md)'s
recovery section says "Take it from `phoenix`'s backup", and no such backup
exists.

Losing the state does not lose a guest. It loses OpenTofu's record of them:
every guest in `tofu/guests.tf` would have to be imported by hand, with its
VMID, disks and cloud-init, before the next `tofu plan` could be trusted. The
rest of `phoenix` is rebuilt by
[`build-the-jumpbox.md`](../runbooks/build-the-jumpbox.md), and its secrets
are restored from escrow or re-issued.

## Decision

**`phoenix` (VMID `170`) joins the nightly backup job on `Saruman`**, with
the Proxmox tag `backup`, in snapshot mode like the rest. Its guest agent is
running, so vzdump freezes its filesystems for the snapshot. `phoenix` is
hand-built, like `odin`, so the tag comes from `qm set 170 --tags`, keeping
its existing tags. `GuestNotInBackupJob` then fires if the VMID ever drops
out of the job.

The whole guest is backed up rather than the one file. It is 30 GB, PBS
deduplicates it across nights, and a restore is §9's `qmrestore`, which the
proof already ran once on this same VMID.

Applied by hand on `Saruman` from `build-the-backup-guest.md` §8, because the
job is not in OpenTofu.

This amends ADR-0053's list of what is backed up. Its target, encryption,
retention and verify job are unchanged.

## Alternatives considered

- **Copy only the state file off `phoenix` on a timer.** It would be smaller.
Declined: it is new code, with its own schedule, target and check, that
does what the existing job already does and watches. It would also need a
credential on `phoenix` to reach somewhere to write, and `phoenix` should
not gain one.
- **Commit the encrypted state.** Declined. ADR-0076 keeps it out of git so a
passphrase leak does not hand over every past version, and git keeps every
version.
- **Accept the loss and fix the runbook's sentence.** Declined. Re-importing
every guest in the lab by hand is days of work, and a nightly backup that
already exists removes that cost.

## Consequences

- **The backup holds every secret `phoenix` holds.** That means the Proxmox
tokens, the domain's passwords, the SSH key and the state, as `security.md`
lists them. vzdump encrypts the chunks on `Saruman` with `golem.enc` before
they leave, so the datastore on `smaug` holds ciphertext. Whoever holds
`golem.enc` and the datastore can read them, and `golem.enc` lives on
`Saruman`, whose `root` already owns `phoenix` and everything it builds. It
is also escrowed as `PBS_ENCRYPTION_KEY` in `secrets/lab.sops.yaml`. No new
holder is created.
- **`provision-lab-guests.md`'s recovery sentence becomes true** once this is
applied: the state comes back with a restore of `170`, or as one file
through PBS's file restore.
- **`alexander`, `gandalf`, `golem` and `eden` stay out**, for ADR-0053's and
ADR-0081's reasons.
- **Reopened by:**
- the state moving off `phoenix`, for instance to a remote backend;
- `phoenix`'s disk growing until the nightly backup's size matters on
`erebor`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# ADR-0144: Allow agent sessions on `phoenix`, and launch no MCP servers there

**Status:** Accepted · 2026-11

## Context

The audit of `phoenix` on 2026-11-13 found a Claude Code agent running on it,
started from the Mac's desktop app over SSH, and two MCP servers that the
session started as local processes: `@modelcontextprotocol/server-pdf`, from
a desktop plugin, and `actual-mcp`, from the Mac's own MCP configuration.
`npx` fetched both at their newest version on the day, unpinned, and they ran
as the operator, who can read `phoenix.env` and has passwordless `sudo` (§6
of [`build-the-jumpbox.md`](../runbooks/build-the-jumpbox.md)). The 2026-11-27
recheck found them still running. `actual-mcp` had no server address or
credential here, so it reached nothing, but its code still ran.

[`security.md`](../security.md) already prices owning `phoenix` as owning the
lab domain. A package that `npx` resolves at launch is code from outside the
repository that runs with that reach, and nothing pins or reviews it.

[ADR-0123](0123-keep-agent-sessions-on-trinity.md) took the same question for
`trinity` and kept Claude Code there, because sessions are how the operator
inspects and maintains the host. The same is true here: the audits of
`phoenix`, ADR-0135's change and this decision were all prepared from an
agent session on it. Nothing in the repository mentioned agents on `phoenix`
until now.

## Decision

**Agent sessions on `phoenix` are accepted** for the work the host exists
for: reading its state, running the toolchain and the repository's checks,
and preparing changes. They are subject to the rules that already bind the
host. `phoenix` has no GitHub credential (the audit's F3), so a session's
change leaves as a patch that the operator pushes from the Mac. Fixes to
anything the repository deploys go through the repository.

**No MCP server is launched on `phoenix`.** A Claude Code managed-settings
file, owned by root, enforces it:

```json
{
"allowManagedMcpServersOnly": true,
"allowedMcpServers": []
}
```

at `/etc/claude-code/managed-settings.json`. An empty allowlist that only
managed settings can extend refuses every MCP server that a plugin, the
user's configuration or a project's `.mcp.json` names, whatever it is called
and however it is started. The operator cannot widen it without `sudo`, and
`sudo` already owns the host. `build-the-jumpbox.md` §6a writes it.

Connectors that the desktop app delivers from claude.ai are not covered by
that file. Claude Code's documentation says they arrive in-process and are
governed from the claude.ai organisation's settings. They run no package on
`phoenix`, so this decision does not need to restrict them.

## Alternatives considered

- **Move agent sessions off `phoenix`.** Declined. The toolchain, the state
and the env files are here, so the session would SSH in to do the same work
with the same reach. That adds a hop and no boundary.
- **Pin the MCP packages and accept them.** Declined. A pinned package still
runs third-party code as a user who owns the lab domain, and neither server
does anything the host's work needs.
- **Deny the two servers by name.** Declined. Claude Code's documentation
says a name is not a security control, because any server can be given any
name. The empty allowlist refuses by default.
- **Turn the plugins and server off on the Mac only.** Declined as the only
control. It is a setting on another host, and the next plugin brings its
own server. Turning them off on the Mac is still worth doing, so that the
refusals do not clutter every session here.

## Consequences

- **A session on `phoenix` has no local MCP tools.** The pdf viewer and the
budget tools are unavailable here. Both belong to other hosts' work.
- **A later audit reads the agent on `phoenix` as this decision, not as a
finding,** and checks that the managed file is in place and that no MCP
server process runs.
- **Reopened by:**
- work on `phoenix` that needs an MCP server. That is a new ADR naming the
server, its pinned version and what it can reach;
- Claude Code changing how managed settings bind remote sessions.
17 changes: 17 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ docstring gives: it is a record, not a claim about now.

## 2026-11-27

- **`phoenix`'s audit closes out (ADR-0143, ADR-0144).** The 2026-11-27
recheck of `phoenix` found its `packer` and `tofu` at 1.16.1 and 1.13.1. The
pins in `stacks/observability/compose.yaml` have been 1.16.2 and 1.13.9 since
the bumps of 2026-11-08 ([#1313](https://github.com/Gerrrt/HomeLab/pull/1313),
[#1319](https://github.com/Gerrrt/HomeLab/pull/1319)), and both runbooks'
`V=` lines still named the old tags. The earlier audit had compared the
binaries with `required_version`, which both still met. Both were
reinstalled from their checksummed release zips the same day, and `tofu
validate` and `packer validate -syntax-only` passed. The two runbooks now
read `V=` from `compose.yaml`. The same recheck found nothing had backed up
`tofu/`'s state since `build-the-backup-guest.md` §9 deleted its proof, so
ADR-0143 adds `phoenix` to the nightly job. It also found the agent session
on `phoenix` still launching two `npx` MCP servers, so ADR-0144 accepts the
sessions and refuses the servers with a managed-settings file.
`build-the-jumpbox.md` §6 gains the textfile-collector step whose absence
left `SecurityUpdatesPending` and `RebootRequired` blind to `phoenix`.
Neither ADR is applied yet.
- **Household wiki swept against the repository
([#1457](https://github.com/Gerrrt/HomeLab/issues/1457)): 269 corrections
on 73 pages.** Every page was read against `network.md`, `hardware.md`,
Expand Down
10 changes: 7 additions & 3 deletions docs/runbooks/build-the-backup-guest.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,15 +421,19 @@ Print it, and keep it where the age key's own backup lives
| --- | --- |
| Storage | `golem` |
| Schedule | `21:00` |
| Selection | `odin` (160), `garuda` (162) and the domain's six, as each is built |
| Selection | `odin` (160), `garuda` (162), `phoenix` (170) and the domain's six, as each is built |
| Mode | Snapshot |
| Retention | *Keep all backups* — PBS's prune job in §6 decides |

On the day this is built, the selection may be empty. That is correct: ADR-0053
backs up the domain and `odin`, and neither may exist yet. **On 2026-10-03,
when it was built, both did**, and the job took all seven from that night. `alexander`,
`phoenix`, `gandalf` and `golem` itself are rebuilt from this repository and
stay out. So does `eden` (141), whose graph is one collection run from rebuilt
`gandalf` and `golem` itself are rebuilt from this repository and stay out.
`phoenix` is in since
[ADR-0143](../adr/0143-back-up-phoenix-for-its-opentofu-state.md):
the rest of it is rebuilt from this repository, but its OpenTofu state is
not. It is hand-built, like `odin`, so `qm set 170 --tags` gives it the
tag, keeping its existing ones. So does `eden` (141), whose graph is one collection run from rebuilt
([ADR-0081](../adr/0081-run-bloodhound-ce-on-a-saruman-guest.md)). `garuda`
is in, because its case notes are in no repository
([ADR-0091](../adr/0091-put-a-kali-purple-analyst-workstation-on-saruman.md)).
Expand Down
41 changes: 41 additions & 0 deletions docs/runbooks/build-the-jumpbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,19 @@ to check the pass to `10.0.30.40:9443`, the answer is that there is no
pass to place — go back to §5, because that message was written for hosts on
another VLAN and this one is not.

**Then the textfile collectors**, also from the Mac. `deploy-agent.sh` needs
no privilege on the target and so installs none of them, and without them
`SecurityUpdatesPending` and `RebootRequired` can never fire for `phoenix`.
The audit of 2026-11-25 found `/var/lib/node_exporter/textfile_collector`
empty for that reason:

```bash
make install-agent-collectors AGENT=<user>@10.0.30.70
make install-agent-collectors AGENT=<user>@10.0.30.70 ARGS=--check
```

The second changes nothing and reports each collector installed.

## 6a. Close the way in

[ADR-0117](../adr/0117-give-phoenix-a-key-only-sshd-and-a-default-deny-inbound-policy.md):
Expand Down Expand Up @@ -542,6 +555,34 @@ it for its own length
- On `phoenix`: §4's `curl` still lists the guests, and §7's Alloy checks
still pass. Both are outbound, and `ufw` allows outbound.

**Then the agent's MCP servers.** Agent sessions on `phoenix` are accepted,
and MCP servers are not launched here
([ADR-0144](../adr/0144-allow-agent-sessions-on-phoenix-and-launch-no-mcp-servers-there.md)).
A Claude Code managed-settings file refuses every one, whatever plugin or
configuration names it:

```bash
sudo install -d -m 755 /etc/claude-code
sudo tee /etc/claude-code/managed-settings.json >/dev/null <<'EOF'
{
"allowManagedMcpServersOnly": true,
"allowedMcpServers": []
}
EOF
sudo chmod 644 /etc/claude-code/managed-settings.json
```

It binds sessions that start after it is written. Start a fresh remote
session, then on `phoenix`:

```bash
pgrep -af 'mcp' || echo 'no MCP server running'
```

After every session that started before the file has closed, it prints
`no MCP server running`. Connectors that the desktop app delivers from
claude.ai run in-process and start no process here.

## 7. Verify — including the thing that fails quietly

```bash
Expand Down
13 changes: 9 additions & 4 deletions docs/runbooks/build-the-lab-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ the day (ADR-0074). Take the `linux_amd64` zip and check it against the

```bash
sudo apt-get install -y curl jq unzip xorriso
V=1.16.1 # the tag compose.yaml pins for packer
cd /tmp \
V=$(sed -nE 's|.*image: hashicorp/packer:([0-9.]+)@.*|\1|p' ~/code/Gerrrt/HomeLab/stacks/observability/compose.yaml) # the tag compose.yaml pins
[ -n "$V" ] \
&& cd /tmp \
&& curl -fsSLO "https://releases.hashicorp.com/packer/${V}/packer_${V}_linux_amd64.zip" \
&& curl -fsSLO "https://releases.hashicorp.com/packer/${V}/packer_${V}_SHA256SUMS" \
&& grep " packer_${V}_linux_amd64.zip$" "packer_${V}_SHA256SUMS" | sha256sum -c - \
Expand All @@ -87,8 +88,12 @@ before anything is unpacked or installed.
`sudo apt-get remove -y packer && sudo rm -f /etc/apt/sources.list.d/hashicorp.list /usr/share/keyrings/hashicorp.gpg`.
Then `command -v packer` should print `/usr/local/bin/packer`.
- **A bump** starts with Dependabot moving the `packer` image in
`stacks/observability/compose.yaml`. `required_version` and `V=` above move
in the same PR; a new minor release fails `packer init` until they do.
`stacks/observability/compose.yaml`. `V=` above reads that tag, so it never
lags; the bumps of 2026-11-08 left a literal `V=` two releases behind, and
`phoenix` with them. `required_version` moves in the same PR for a new
minor release, which fails `packer init` until it does. After the merge,
rerun this block on `phoenix`, and the same for `tofu` in
`provision-lab-guests.md` §1.

Then fetch the plugin `packer/versions.pkr.hcl` pins:

Expand Down
8 changes: 6 additions & 2 deletions docs/runbooks/provision-lab-guests.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ OpenTofu's GitHub release and check it against the `SHA256SUMS` published
beside it:

```bash
V=1.13.1 # the tag compose.yaml pins for tofu
V=$(sed -nE 's|.*image: ghcr.io/opentofu/opentofu:([0-9.]+)@.*|\1|p' ~/code/Gerrrt/HomeLab/stacks/observability/compose.yaml) # the tag compose.yaml pins
echo "$V" # empty means the pattern no longer matches: stop
cd /tmp
curl -fsSLO "https://github.com/opentofu/opentofu/releases/download/v${V}/tofu_${V}_linux_amd64.zip"
curl -fsSLO "https://github.com/opentofu/opentofu/releases/download/v${V}/tofu_${V}_SHA256SUMS"
Expand Down Expand Up @@ -308,7 +309,10 @@ replaces the guest, and replacing it re-clones it from scratch.

## Recovery: `phoenix` is gone

The state is only recoverable if its file is. Take it from `phoenix`'s backup.
The state is only recoverable if its file is. Take it from `phoenix`'s nightly
backup on `golem` ([ADR-0143](../adr/0143-back-up-phoenix-for-its-opentofu-state.md)): restore VMID `170` as
[`build-the-backup-guest.md`](build-the-backup-guest.md) §9 does, or take the one
file with PBS's file restore.
The passphrase comes from escrow, on `prometheus`:

```bash
Expand Down
14 changes: 14 additions & 0 deletions docs/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,20 @@ assumption consistent with what they are.
permissions and the token's scope: `PhoenixBuilder` on named paths, never at
`/`. That scope is the sentence to argue with, because whoever holds the
token can create and destroy guests.

[ADR-0143](adr/0143-back-up-phoenix-for-its-opentofu-state.md) adds
`phoenix` to the nightly backup for the state, so a copy of all of them
leaves the host every night, encrypted on `Saruman` with `golem.enc` before
it reaches `smaug`. That key's holders, `Saruman`'s `root` and the lab's
SOPS file, already reach everything `phoenix` holds. Decided, not yet
applied.
- **Agent sessions on `phoenix` are accepted, and launch no MCP server**
([ADR-0144](adr/0144-allow-agent-sessions-on-phoenix-and-launch-no-mcp-servers-there.md)).
A session runs as the operator, with all of the reach above. What it may
not do is run a package fetched at launch: a root-owned Claude Code
managed-settings file refuses every MCP server a plugin or a
configuration names. `phoenix` has no GitHub credential, so a session's
changes leave as a patch the operator pushes. Decided, not yet applied.
- **The alert path's credentials are in SOPS on two hosts, and one of them
crosses the CA boundary on purpose.** Since
[#136](https://github.com/Gerrrt/HomeLab/issues/136) Alertmanager delivers to
Expand Down