feat: ansible-smoke phase for podman apt-src tracks
This commit is contained in:
parent
4e4e6a2925
commit
18a4fec2dd
1 changed files with 182 additions and 0 deletions
182
check_ansible_smoke.sh
Executable file
182
check_ansible_smoke.sh
Executable file
|
|
@ -0,0 +1,182 @@
|
|||
#!/usr/bin/env bash
|
||||
# check_ansible_smoke.sh — taler-deployment ansible / apt full-stack smoke (TASK112)
|
||||
#
|
||||
# Goals (from REF106/TASK112):
|
||||
# Container try-install against Taler apt for: trixie · trixie-testing · Ubuntu
|
||||
# PASS/FAIL artifact. Source-build path is out of scope (open-work later).
|
||||
#
|
||||
# This phase is opt-in (not in default PHASES). Prefer running on a host with
|
||||
# podman (koopa). On laptops without containers it still syntax-checks ansible
|
||||
# when TALER_DEPLOYMENT is set.
|
||||
#
|
||||
# Env:
|
||||
# TALER_DEPLOYMENT path to taler-deployment.git checkout
|
||||
# ANSIBLE_SMOKE_SKIP=1
|
||||
# ANSIBLE_SMOKE_PODMAN=1 inventory podman apt-src tracks (default 0 on non-koopa)
|
||||
# ANSIBLE_SMOKE_ARTIFACT output dir (default: $HTML_OUT or /tmp/taler-ansible-smoke)
|
||||
# ANSIBLE_SMOKE_UBUNTU_CONTAINER name (default koopa-taler-deploy-test-apt-src-ubuntu)
|
||||
# ANSIBLE_SMOKE_REQUIRE_UBUNTU=1 hard-fail when ubuntu container missing
|
||||
#
|
||||
set -euo pipefail
|
||||
ROOT=$(cd "$(dirname "$0")" && pwd)
|
||||
# shellcheck source=lib.sh
|
||||
source "$ROOT/lib.sh"
|
||||
|
||||
if [ "${ANSIBLE_SMOKE_SKIP:-0}" = "1" ]; then
|
||||
echo "[INFO] skip phase ansible-smoke (ANSIBLE_SMOKE_SKIP=1)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
set_area ansible-smoke
|
||||
section "ansible-smoke · taler-deployment full-stack (trixie / trixie-testing / Ubuntu)"
|
||||
|
||||
DEPLOY="${TALER_DEPLOYMENT:-${TALER_DEPLOYMENT_ROOT:-}}"
|
||||
if [ -z "$DEPLOY" ]; then
|
||||
for c in \
|
||||
"${HOME}/src/taler-deployment" \
|
||||
"${HOME}/git/taler-deployment" \
|
||||
"${SUITE_DIR:+$SUITE_DIR/../taler-deployment}"; do
|
||||
[ -n "$c" ] && [ -d "$c/regional-currency-ng" ] && DEPLOY=$c && break
|
||||
done
|
||||
fi
|
||||
|
||||
ART="${ANSIBLE_SMOKE_ARTIFACT:-${HTML_OUT:-/tmp}/taler-ansible-smoke}"
|
||||
mkdir -p "$ART"
|
||||
STAMP=$(date -u +%Y%m%dT%H%M%SZ)
|
||||
REPORT="$ART/report-$STAMP.txt"
|
||||
: >"$REPORT"
|
||||
log() { printf '%s\n' "$*" | tee -a "$REPORT"; }
|
||||
|
||||
log "host=$(hostname 2>/dev/null || echo unknown) ts=$STAMP"
|
||||
log "deploy=${DEPLOY:-MISSING}"
|
||||
|
||||
fail=0
|
||||
# On koopa, taler-deployment.git is often absent; podman track inventory still useful.
|
||||
if [ -z "$DEPLOY" ] || [ ! -d "$DEPLOY/regional-currency-ng" ]; then
|
||||
if [ "${ANSIBLE_SMOKE_PODMAN:-0}" = "1" ]; then
|
||||
info "deploy-tree" "taler-deployment missing — syntax-check skipped; continuing podman track inventory"
|
||||
log "SKIP deploy-tree (set TALER_DEPLOYMENT for syntax-check)"
|
||||
else
|
||||
err "deploy-tree" "taler-deployment regional-currency-ng not found (set TALER_DEPLOYMENT)"
|
||||
fail=1
|
||||
fi
|
||||
else
|
||||
ok "deploy-tree" "$DEPLOY/regional-currency-ng"
|
||||
RC_NG="$DEPLOY/regional-currency-ng"
|
||||
if [ -f "$RC_NG/site.yml" ]; then
|
||||
ok "site.yml" "present"
|
||||
else
|
||||
err "site.yml" "missing"
|
||||
fail=1
|
||||
fi
|
||||
if command -v ansible-playbook >/dev/null 2>&1; then
|
||||
ok "ansible-playbook" "$(ansible-playbook --version 2>/dev/null | head -1)"
|
||||
if ansible-playbook --syntax-check -i "$RC_NG/inventory.example.yml" "$RC_NG/site.yml" \
|
||||
>>"$REPORT" 2>&1; then
|
||||
ok "syntax-check" "site.yml + inventory.example.yml"
|
||||
log "PASS syntax-check"
|
||||
else
|
||||
err "syntax-check" "ansible-playbook --syntax-check failed (see $REPORT)"
|
||||
fail=1
|
||||
log "FAIL syntax-check"
|
||||
fi
|
||||
else
|
||||
info "ansible-playbook" "not installed — syntax-check skipped"
|
||||
log "SKIP syntax-check (no ansible-playbook)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Container apt tracks: reuse aptdeploy naming; Ubuntu track is additive.
|
||||
# Heavy merchant install stays in check_apt_deploy.sh; here we inventory tracks.
|
||||
TARGETS="trixie trixie-testing ubuntu"
|
||||
log "targets=$TARGETS"
|
||||
UBUNTU_NAME="${ANSIBLE_SMOKE_UBUNTU_CONTAINER:-koopa-taler-deploy-test-apt-src-ubuntu}"
|
||||
REQUIRE_UBUNTU="${ANSIBLE_SMOKE_REQUIRE_UBUNTU:-0}"
|
||||
|
||||
_podman_track_state() {
|
||||
# stdout: running|exited|missing
|
||||
local bin=$1 name=$2
|
||||
if "$bin" inspect -f '{{.State.Status}}' "$name" >/dev/null 2>&1; then
|
||||
"$bin" inspect -f '{{.State.Status}}' "$name" 2>/dev/null | tr -d '\r'
|
||||
else
|
||||
printf '%s\n' missing
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "${ANSIBLE_SMOKE_PODMAN:-0}" = "1" ]; then
|
||||
PODMAN_BIN="${APT_DEPLOY_PODMAN:-podman}"
|
||||
if ! command -v "$PODMAN_BIN" >/dev/null 2>&1; then
|
||||
err "podman" "ANSIBLE_SMOKE_PODMAN=1 but podman missing"
|
||||
fail=1
|
||||
else
|
||||
ok "podman" "$("$PODMAN_BIN" --version 2>/dev/null | head -1)"
|
||||
log "NOTE: full container install remains check_apt_deploy.sh (trixie tracks)."
|
||||
|
||||
for suite in trixie trixie-testing; do
|
||||
for mode in "" "-upgrade"; do
|
||||
cname="koopa-taler-deploy-test-apt-src-${suite}${mode}"
|
||||
st=$(_podman_track_state "$PODMAN_BIN" "$cname")
|
||||
case "$st" in
|
||||
running|created)
|
||||
ok "track-$suite${mode:-}" "$cname state=$st"
|
||||
log "PASS track $cname state=$st"
|
||||
;;
|
||||
exited|stopped)
|
||||
info "track-$suite${mode:-}" "$cname state=$st (present, not running)"
|
||||
log "WARN track $cname state=$st"
|
||||
;;
|
||||
*)
|
||||
info "track-$suite${mode:-}" "$cname missing"
|
||||
log "MISS track $cname"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
done
|
||||
|
||||
# Ubuntu track (additive; create image/container only with Freigabe on koopa)
|
||||
ust=$(_podman_track_state "$PODMAN_BIN" "$UBUNTU_NAME")
|
||||
case "$ust" in
|
||||
running|created)
|
||||
ok "track-ubuntu" "$UBUNTU_NAME state=$ust"
|
||||
log "PASS track $UBUNTU_NAME state=$ust"
|
||||
;;
|
||||
exited|stopped)
|
||||
info "track-ubuntu" "$UBUNTU_NAME state=$ust (present, not running)"
|
||||
log "WARN track $UBUNTU_NAME state=$ust"
|
||||
;;
|
||||
*)
|
||||
if [ "$REQUIRE_UBUNTU" = "1" ]; then
|
||||
err "track-ubuntu" "$UBUNTU_NAME missing (ANSIBLE_SMOKE_REQUIRE_UBUNTU=1)"
|
||||
fail=1
|
||||
log "FAIL track $UBUNTU_NAME missing"
|
||||
else
|
||||
info "track-ubuntu" "$UBUNTU_NAME missing — Freigabe needed to create ubuntu apt-src image/container"
|
||||
log "TODO ubuntu: create $UBUNTU_NAME (Freigabe); soft-miss until then"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if "$PODMAN_BIN" image exists "docker.io/library/ubuntu:24.04" 2>/dev/null \
|
||||
|| "$PODMAN_BIN" image exists "ubuntu:24.04" 2>/dev/null; then
|
||||
ok "ubuntu-base-image" "ubuntu:24.04 present"
|
||||
log "PASS ubuntu-base-image"
|
||||
else
|
||||
info "ubuntu-base-image" "ubuntu:24.04 not pulled yet (optional)"
|
||||
log "MISS ubuntu-base-image"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
info "podman-smoke" "skipped (set ANSIBLE_SMOKE_PODMAN=1 on koopa)"
|
||||
log "SKIP podman-smoke"
|
||||
fi
|
||||
|
||||
if [ "$fail" -eq 0 ]; then
|
||||
log "OVERALL=PASS"
|
||||
ok "ansible-smoke" "PASS · artifact $REPORT"
|
||||
else
|
||||
log "OVERALL=FAIL"
|
||||
err "ansible-smoke" "FAIL · artifact $REPORT"
|
||||
fi
|
||||
info "artifact" "$REPORT"
|
||||
summary
|
||||
exit "$fail"
|
||||
Reference in a new issue