Agent host check: run every step, and say so
CI / checks (push) Skipped
CI / checks (pull_request) Successful in 2m7s
CI / e2e (pull_request) Successful in 3m59s

The check went to the host on stdin, and the first docker compose exec read
the rest of it: the memory and firewall checks never ran, and it passed.
It is now its own file, sent as an argument, and ends with "all checks
passed" only when every check has run. Tests fake the host with a docker
that reads stdin.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J5Utyfzw7gF7UhjRDEtjTk
This commit is contained in:
dongarandClaude Opus 5.5 committed 2026-10-19 14:48:31 +00:00
1 parent 454326e750
commit 5ab0861e8e
4 files changed
+104 -24

No files matched your search

+5 -24
View File
@@ -4,7 +4,8 @@
# scripts/agent-host.sh check check SilverBullet runs and the mounts and
# firewall hold
# scripts/agent-host.sh ssh ... run a command on the host
# Trusts only the host keys bot-ansible posted (~/bin/tofu-wait.sh saved them).
# Trusts only host keys from a trusted source: bot-ansible's comment
# (~/bin/tofu-wait.sh saves them) or the operator, read off the console.
set -euo pipefail
host=${AGENT_HOST:-nisse.garrett-hall.com}
@@ -23,29 +24,9 @@ case ${1:-} in
on_host 'rm -rf /tmp/agent-host && tar -C /tmp -xf - && sudo bash /tmp/agent-host/setup.sh'
;;
check)
on_host 'bash -s' <<'EOF'
set -u
fail=0
ok() { echo "ok: $1"; }
bad() { echo "FAIL: $1"; fail=1; }
cd /opt/stacks/silverbullet
[ "$(sudo docker compose ps --status running -q | wc -l)" -ge 1 ] \
&& ok "SilverBullet is running" || bad "SilverBullet isn't running"
code=$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:3000/)
case $code in 2??|3??) ok "it answers locally ($code)" ;; *) bad "it answers $code" ;; esac
probe=.nisse-probe-$$
sudo docker compose exec -T -u 1000 silverbullet sh -c "touch /vault/infrastructure/$probe && rm /vault/infrastructure/$probe" \
&& ok "the operator's folders are writable" || bad "the operator's folders aren't writable"
if sudo docker compose exec -T silverbullet sh -c "touch /vault/memory/$probe" 2>/dev/null; then
sudo docker compose exec -T silverbullet rm -f "/vault/memory/$probe"
bad "memory/ is writable from SilverBullet, even as root in it"
else
ok "memory/ is read-only to SilverBullet"
fi
sudo iptables -S DOCKER-USER | grep -q -- '--comment nisse-firewall' \
&& ok "the firewall rule is in place" || bad "no firewall rule"
exit $fail
EOF
# As an argument, not on stdin: docker compose exec reads stdin, and would
# swallow the rest of a script fed that way.
on_host "bash -c $(printf '%q' "$(cat "$repo/deploy/agent-host/check.sh")")"
;;
ssh)
shift