mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-10 12:47:04 +00:00
Replace 8 bash env modules with a single Python generator
(cli.meta.env) that materialises env/static.env + runtime context
into a gitignored .env. Each variable lives in its own handler
under utils/env/handlers/; defaults carry inline one-line `# ...`
comments.
Rename to the INFINITO_* schema:
- workflow inputs: APPS, SERVICES_DISABLED, CMD, DEBUG, WHITELIST,
BUNDLES, FULL_CYCLE, VARIANT, RUN_FLAGS, LIMIT_HOST, PARALLEL
- inventory: INVENTORY_DIR / INVENTORY_FILE / HOST_VARS_FILE,
PW_FILE -> INVENTORY_PASSWORD_FILE
- venv: VENV_BASE / VENV_FALLBACK / VENV_NAME
- new SPOT defaults: COMPILE_SILENCE, CONTAINER_NO_CA,
WAIT_HEALTH_TIMEOUT_S, PACKAGE_CACHE_FRONTEND_INIT_IMAGE,
promoted IMAGE_TAG from GHA-only to general passthrough
compose.yml hardening:
- inline \${VAR:-default} removed; strict \${VAR:?...} everywhere
- new integration lint blocks regressions
Tooling:
- scripts/install/all.sh owns the stamp-file install logic
(Makefile target delegates)
- scripts/meta/env/load.sh is the single shell entry point;
8 bash modules deleted
- new shell lint: no INFINITO_* defaults outside env/static.env
Tests:
- 93 new unit tests for utils/env/{builder,parser,runtime,writer}
- restructure tests/lint into repository/ (file-content rules) vs
filesystem/{shell,python,env}/ (filesystem-shape rules)
- drift + smoke integration tests against the generator
Docs:
- variables.md is now a pointer; per-variable docs live next to
the key in env/static.env / env/ci.env
- compose.yml.md drops the Default column
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
168 lines
5.4 KiB
Bash
Executable File
168 lines
5.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# ------------------------------------------------------------
|
|
# Load environment (Single Source of Truth)
|
|
# ------------------------------------------------------------
|
|
ENV_FILE="${ENV_FILE:-env/ci.env}"
|
|
|
|
if [ ! -f "${ENV_FILE}" ]; then
|
|
echo "ERROR: env file not found: ${ENV_FILE}"
|
|
exit 1
|
|
fi
|
|
|
|
# Export all variables from env file
|
|
set -a
|
|
# shellcheck disable=SC1090
|
|
source "${ENV_FILE}"
|
|
set +a
|
|
|
|
# Source project defaults so INFINITO_CONTAINER auto-derives from
|
|
# INFINITO_DISTRO (single SPOT in scripts/meta/env/load.sh) — callers
|
|
# only need to set INFINITO_DISTRO.
|
|
# shellcheck source=scripts/meta/env/load.sh
|
|
source scripts/meta/env/load.sh
|
|
|
|
# ------------------------------------------------------------
|
|
# Required variables (fail hard if missing)
|
|
# ------------------------------------------------------------
|
|
: "${INFINITO_DNS_IP:?Missing INFINITO_DNS_IP in env file}"
|
|
: "${INFINITO_DOMAIN:?Missing INFINITO_DOMAIN in env file}"
|
|
: "${INFINITO_IP4:?Missing INFINITO_IP4 in env file}"
|
|
: "${INFINITO_CONTAINER:?Missing INFINITO_CONTAINER env (e.g. infinito_nexus_arch)}"
|
|
|
|
SUBDOMAIN="foo.${INFINITO_DOMAIN}"
|
|
IP4_EXPECTED="${INFINITO_IP4}"
|
|
|
|
# ------------------------------------------------------------
|
|
# Output helpers
|
|
# ------------------------------------------------------------
|
|
section() {
|
|
echo
|
|
echo "------------------------------------------------------------"
|
|
echo "$1"
|
|
echo "------------------------------------------------------------"
|
|
}
|
|
|
|
ok() { echo "OK: $*"; }
|
|
warn() { echo "WARN: $*"; }
|
|
fail() {
|
|
echo "FAIL: $*"
|
|
exit 1
|
|
}
|
|
|
|
# ------------------------------------------------------------
|
|
# Banner
|
|
# ------------------------------------------------------------
|
|
echo "============================================================"
|
|
echo " DNS TEST SUITE"
|
|
echo "============================================================"
|
|
echo "ENV_FILE = ${ENV_FILE}"
|
|
echo "INFINITO_DNS_IP = ${INFINITO_DNS_IP}"
|
|
echo "INFINITO_DOMAIN = ${INFINITO_DOMAIN}"
|
|
echo "SUBDOMAIN = ${SUBDOMAIN}"
|
|
echo "EXPECT IP = ${IP4_EXPECTED}"
|
|
echo "INFINITO = ${INFINITO_CONTAINER}"
|
|
echo
|
|
|
|
# ------------------------------------------------------------
|
|
# Host -> CoreDNS direct
|
|
# ------------------------------------------------------------
|
|
section "Host -> CoreDNS (direct queries)"
|
|
|
|
if command -v dig >/dev/null 2>&1; then
|
|
a1="$(dig @"${INFINITO_DNS_IP}" "${INFINITO_DOMAIN}" A +short | head -n1 || true)"
|
|
a2="$(dig @"${INFINITO_DNS_IP}" "${SUBDOMAIN}" A +short | head -n1 || true)"
|
|
|
|
if [ "${a1}" = "${IP4_EXPECTED}" ]; then
|
|
ok "${INFINITO_DOMAIN} A -> ${a1}"
|
|
else
|
|
fail "${INFINITO_DOMAIN} A failed (got '${a1}')"
|
|
fi
|
|
|
|
if [ "${a2}" = "${IP4_EXPECTED}" ]; then
|
|
ok "${SUBDOMAIN} A -> ${a2}"
|
|
else
|
|
fail "${SUBDOMAIN} A failed (got '${a2}')"
|
|
fi
|
|
else
|
|
warn "dig not found on host — skipping host direct DNS tests"
|
|
fi
|
|
|
|
# ------------------------------------------------------------
|
|
# Host -> CoreDNS AAAA sanity check (must NOT return SERVFAIL)
|
|
# ------------------------------------------------------------
|
|
section "Host -> CoreDNS (AAAA sanity check)"
|
|
|
|
if command -v dig >/dev/null 2>&1; then
|
|
aaaa1="$(dig @"${INFINITO_DNS_IP}" "${INFINITO_DOMAIN}" AAAA +comments +noall +answer || true)"
|
|
aaaa2="$(dig @"${INFINITO_DNS_IP}" "${SUBDOMAIN}" AAAA +comments +noall +answer || true)"
|
|
|
|
echo "AAAA ${INFINITO_DOMAIN}:"
|
|
echo "${aaaa1:-<empty>}"
|
|
echo
|
|
|
|
echo "AAAA ${SUBDOMAIN}:"
|
|
echo "${aaaa2:-<empty>}"
|
|
echo
|
|
|
|
# dig exits 0 even on NXDOMAIN, so we check for SERVFAIL explicitly
|
|
status1="$(dig @"${INFINITO_DNS_IP}" "${INFINITO_DOMAIN}" AAAA +comments 2>&1 | grep -i status || true)"
|
|
status2="$(dig @"${INFINITO_DNS_IP}" "${SUBDOMAIN}" AAAA +comments 2>&1 | grep -i status || true)"
|
|
|
|
echo "${status1}"
|
|
echo "${status2}"
|
|
|
|
echo "${status1}" | grep -qi "SERVFAIL" && fail "AAAA lookup returned SERVFAIL for ${INFINITO_DOMAIN}"
|
|
echo "${status2}" | grep -qi "SERVFAIL" && fail "AAAA lookup returned SERVFAIL for ${SUBDOMAIN}"
|
|
|
|
ok "AAAA sanity check passed (no SERVFAIL)"
|
|
else
|
|
warn "dig not found on host — skipping AAAA sanity test"
|
|
fi
|
|
|
|
# ------------------------------------------------------------
|
|
# CoreDNS container
|
|
# ------------------------------------------------------------
|
|
section "CoreDNS container status"
|
|
|
|
if docker ps --filter name=infinito-coredns --format '{{.Names}}' | grep -q infinito-coredns; then
|
|
docker ps --filter name=infinito-coredns --format 'table {{.Names}}\t{{.Status}}\t{{.Image}}'
|
|
container logs --tail=10 infinito-coredns || true
|
|
ok "CoreDNS container is running"
|
|
else
|
|
fail "CoreDNS container not running"
|
|
fi
|
|
|
|
# ------------------------------------------------------------
|
|
# Infinito outer container DNS
|
|
# ------------------------------------------------------------
|
|
section "Infinito container (outer) DNS"
|
|
|
|
docker exec "${INFINITO_CONTAINER}" sh -lc "
|
|
set -e
|
|
|
|
echo '>>> /etc/resolv.conf'
|
|
cat /etc/resolv.conf || true
|
|
echo
|
|
|
|
echo '>>> getent hosts'
|
|
h1=\$(getent hosts ${INFINITO_DOMAIN} | awk '{print \$1}' || true)
|
|
h2=\$(getent hosts ${SUBDOMAIN} | awk '{print \$1}' || true)
|
|
|
|
echo \"${INFINITO_DOMAIN} -> \${h1}\"
|
|
echo \"${SUBDOMAIN} -> \${h2}\"
|
|
|
|
[ \"\${h1}\" = \"${IP4_EXPECTED}\" ] || exit 11
|
|
[ \"\${h2}\" = \"${IP4_EXPECTED}\" ] || exit 12
|
|
"
|
|
|
|
ok "Outer container DNS works"
|
|
|
|
# ------------------------------------------------------------
|
|
# DONE
|
|
# ------------------------------------------------------------
|
|
section "DONE"
|
|
echo "DNS chain is fully functional:"
|
|
echo "Host -> CoreDNS -> Outer container -> Inner container"
|