Files
computer-playbook/scripts/github/guide/host_deploy.sh
T
kevinveenbirkenbachandClaude Opus 4.8 972596a758 fix(guide): document the administrator SSH key step and seed it in CI via --vars
The README Production block went provision -> deploy with no admin-key step, so user-administrator failed early (authorized_keys empty) for both the Guide CI jobs and any real user copying the README. Add a visible 'provision --vars' step that sets users.administrator.authorized_keys (merged into host_vars) in both Production variants of the role README template, regenerate all role READMEs, and replace the invisible CI payload splice with a visible substitution of the documented <your-ssh-public-key> placeholder.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-20 05:45:26 +02:00

35 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Install a host role inside its pkgmgr distro container against localhost.
# Env: GUIDE_ROLE, GUIDE_RUNTIME_IMAGE.
set -euo pipefail
# Exception: strip the clone/cd lines because the checkout is already
# mounted; running them would clone a fresh tree and lose the CI changes.
awk '/^### Production$/{p=1} p && /^```bash$/{c=1; next} c && /^```$/{exit} c' \
"roles/${GUIDE_ROLE}/README.md" |
grep -vE '^git clone |^cd core$' >/tmp/host-deploy.sh
test -s /tmp/host-deploy.sh
sed -i "s#<your-ssh-public-key>#ssh-ed25519 AAAA_TEST_DUMMY_KEY github-ci-dummy@infinito#" /tmp/host-deploy.sh
docker pull "${GUIDE_RUNTIME_IMAGE}"
# Exception: boot systemd as PID 1 because the host role manages user
# timers/units; enable-linger below gives root a --user manager.
CID="$(docker run -d --privileged --cgroupns=host \
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
--tmpfs /run --tmpfs /run/lock \
-v "${PWD}:${PWD}" \
--entrypoint /sbin/init \
"${GUIDE_RUNTIME_IMAGE}")"
trap 'docker rm -f "${CID}" >/dev/null 2>&1 || true' EXIT
for _ in $(seq 1 40); do
state="$(docker exec "${CID}" systemctl is-system-running 2>/dev/null || true)"
case "${state}" in running | degraded) break ;; esac
sleep 3
done
docker exec "${CID}" systemctl is-system-running 2>/dev/null | grep -qE 'running|degraded'
docker exec "${CID}" bash -lc 'loginctl enable-linger root && systemctl start user@0.service'
docker exec -i -w "${PWD}" "${CID}" bash -s </tmp/host-deploy.sh