mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-08 19:56:53 +00:00
Cosmos, Quick Setup and Credits follow from meta/services.yml, categories.yml and galaxy_info.author, yet 279 role READMEs carried a copy that went stale whenever the metadata moved and nobody re-ran make docs. The documentation build now runs the generators itself, against its own scratch checkout, and the committed READMEs keep only the prose a person writes. utils.cache.PROJECT_ROOT derives from the module's location, so putting the checkout first on PYTHONPATH makes the generator operate on the scratch tree. i18n.py and builder.py add it; the one remaining coupling, a relative_to over PROJECT_ROOT in a log line, is gone. CI extracted the "### Production" block from the committed README with awk. Stripping the section made guide_deployable() return "" for every role, which selects no deploy row and turns nothing red: a fail-open regression. It now asks _is_role_invokable, which matches the old condition exactly (178 roles either way, both difference sets empty), and cli/build/docs/readme/production.py renders the block for the two guide scripts. All 178 renders are byte-identical to what HEAD served, and both scripts' extraction pipelines produce identical output for a web app, a service and a desktop role. test_readme.py inverts: the three sections are now a hard failure in a committed README. readme_md.md documents what each is derived from. Removed: the docs, cosmos, readme-generate, readme-index and readme-check targets, the five aliases pointing at them, and docs from make quality. Verified by running generate_commands() in series against a copy of the checkout: every command exits 0, no README is left without Cosmos or Credits, and exactly the 178 invokable roles get a Quick Setup. The ansible_roles step needs pandoc, which only the docs image carries, so that one link of the chain is unexercised here; it is unchanged by this commit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
77 lines
3.9 KiB
Bash
Executable File
77 lines
3.9 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, INFINITO_DISTRO,
|
|
# INFINITO_RESCUE_DIAGNOSTICS_BASE.
|
|
set -euo pipefail
|
|
|
|
: "${INFINITO_RESCUE_DIAGNOSTICS_BASE:?}"
|
|
: "${INFINITO_DISTRO:?}"
|
|
|
|
# Exception: strip the clone/cd lines because the checkout is already
|
|
# mounted; running them would clone a fresh tree and lose the CI changes.
|
|
python3 -m cli.build.docs.readme.production "${GUIDE_ROLE}" |
|
|
grep -vE '^git clone |^cd core$' >/tmp/host-deploy.sh
|
|
test -s /tmp/host-deploy.sh
|
|
|
|
# shellcheck source=/dev/null
|
|
source scripts/meta/env/load.sh
|
|
sed -i "s#<your-ssh-public-key>#ssh-ed25519 AAAA_TEST_DUMMY_KEY github-ci-dummy@infinito#" /tmp/host-deploy.sh
|
|
sed -i "s#<your-domain>#${INFINITO_DOMAIN}#" /tmp/host-deploy.sh
|
|
|
|
docker pull "${GUIDE_RUNTIME_IMAGE}"
|
|
|
|
# Exception: the pkgmgr base image ships no init of its own.
|
|
PREP="$(docker run -d --entrypoint sleep "${GUIDE_RUNTIME_IMAGE}" infinity)"
|
|
docker exec "${PREP}" sh -c '
|
|
set -e
|
|
if command -v apt-get >/dev/null 2>&1; then
|
|
APT_TIMEOUT=10m
|
|
APT_OPTS="-o Acquire::Retries=5 -o Acquire::http::Timeout=30 -o Acquire::https::Timeout=30"
|
|
timeout -k 30 "$APT_TIMEOUT" apt-get $APT_OPTS update
|
|
DEBIAN_FRONTEND=noninteractive timeout -k 30 "$APT_TIMEOUT" apt-get $APT_OPTS install -y systemd systemd-sysv libnss-myhostname
|
|
elif command -v dnf >/dev/null 2>&1; then
|
|
dnf install -y systemd
|
|
elif command -v pacman >/dev/null 2>&1; then
|
|
pacman -Sy --noconfirm --needed archlinux-keyring
|
|
pacman -Syu --noconfirm --needed systemd
|
|
rm -rf /var/cache/pacman/pkg/*
|
|
fi
|
|
grep -q myhostname /etc/nsswitch.conf || sed -i "s/^hosts:.*/& myhostname/" /etc/nsswitch.conf
|
|
[ -e /sbin/init ] || ln -sf /lib/systemd/systemd /sbin/init
|
|
'
|
|
BOOT_IMAGE="guide-boot:${GUIDE_ROLE}"
|
|
docker commit "${PREP}" "${BOOT_IMAGE}" >/dev/null
|
|
docker rm -f "${PREP}" >/dev/null 2>&1 || true # nocheck: shell-or-true -- cleanup of a possibly already-removed container
|
|
|
|
python3 -c 'from pathlib import Path; from cli.administration.deploy.development.coredns import CoreDNSCorefileRenderer; CoreDNSCorefileRenderer(repo_root=Path(".")).render(show_preview=False)'
|
|
docker compose up -d coredns
|
|
GUIDE_NET="$(docker inspect -f '{{range $k, $v := .NetworkSettings.Networks}}{{$k}}{{end}}' "${INFINITO_RUNNER_PREFIX}-coredns")"
|
|
|
|
CID="$(docker run -d --privileged --cgroupns=host \
|
|
--network "${GUIDE_NET}" --ip "${INFINITO_IP4}" --dns "${INFINITO_DNS_IP}" \
|
|
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
|
|
--tmpfs /run --tmpfs /run/lock \
|
|
-v /srv \
|
|
-v "${PWD}:${PWD}" \
|
|
--entrypoint /sbin/init \
|
|
"${BOOT_IMAGE}")"
|
|
# shellcheck disable=SC2154
|
|
trap 'rc=$?; if [ "${rc}" -ne 0 ]; then _rescue="${INFINITO_RESCUE_DIAGNOSTICS_BASE}/${INFINITO_DISTRO}/${GUIDE_ROLE}"; INFINITO_RESCUE_DIAGNOSTICS_DIR="${_rescue}" python3 utils/diagnostics/container.py "${GUIDE_ROLE}" "guide host boot failure" || true; bash scripts/tests/deploy/utils/rescue_index.sh "${_rescue}"; fi; docker rm -f -v "${CID}" >/dev/null 2>&1 || true; docker compose down >/dev/null 2>&1 || true; docker rmi -f "${BOOT_IMAGE}" >/dev/null 2>&1 || true' EXIT # nocheck: shell-or-true -- best-effort diagnostics + teardown in the EXIT trap
|
|
|
|
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
|
|
state="$(docker exec "${CID}" systemctl is-system-running 2>/dev/null || true)"
|
|
case "${state}" in
|
|
running | degraded) ;;
|
|
*)
|
|
echo "systemd never reached a running state (last: ${state:-unknown})" >&2
|
|
docker exec "${CID}" systemctl --no-pager status 2>/dev/null | head -n 20 >&2 || true # nocheck: shell-or-true -- diagnostics dump on the failure path
|
|
exit 1
|
|
;;
|
|
esac
|
|
docker exec "${CID}" bash -lc 'systemctl unmask systemd-logind && systemctl start systemd-logind && loginctl enable-linger root && systemctl start user@0.service'
|
|
docker exec -i -w "${PWD}" "${CID}" bash -s </tmp/host-deploy.sh
|