Files
computer-playbook/scripts/tests/deploy/local/utils/reuse-kept-app-deploy.sh
T
kevinveenbirkenbachandClaude Opus 4.7 ffea45b163 fix(test-env): pin matomo reuse-pass to VARIANT=0 + suggest sibling inventories on miss
09_deploy_reuse.sh ran `make deploy-reuse-kept-apps APPS=web-app-matomo`
without VARIANT, which makes reuse-kept-app.sh fall back to the
unsuffixed `${INVENTORY_DIR}` path. The matrix-init in step 08 only
writes `${INVENTORY_DIR}-0` / `-1` because matomo declares 2 variants
(see roles/web-app-matomo/meta/variants.yml; planner contract:
cli/administration/deploy/development/inventory/planner.py:107), so
the reuse pass always missed the inventory and aborted with exit 2.

Also surface sibling inventory dirs as suggestions when the lookup
misses, so the next caller hitting this gets a hint instead of a bare
ENOENT.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 11:45:44 +02:00

72 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# In-container helper for `make deploy-reuse-kept-apps`.
#
# Called from the host wrapper at
# scripts/tests/deploy/local/deploy/reuse-kept-app.sh via `docker exec`,
# which is responsible for injecting the env-vars asserted below. The
# repo is mounted at /opt/src/infinito by the dev compose stack.
#
# Required env:
# INVENTORY_FILE absolute path to <inv>/devices.yml
# APPS space-separated app id list for `--id`
# DEBUG "true"|"false" — appends `--debug` when true
set -euo pipefail
cd /opt/src/infinito
: "${INVENTORY_FILE:?INVENTORY_FILE must be set}"
: "${APPS:?APPS must be set}"
: "${DEBUG:?DEBUG must be set}"
inv_dir="$(dirname "${INVENTORY_FILE}")"
pw_file="${inv_dir}/.password"
if [[ ! -f "${INVENTORY_FILE}" ]]; then
echo "ERROR: inventory not found: ${INVENTORY_FILE}" >&2
parent_dir="$(dirname "${inv_dir}")"
if [[ -d "${parent_dir}" ]]; then
shopt -s nullglob
suggestions=()
for sibling in "${parent_dir}"/*/devices.yml; do
[[ "${sibling}" != "${INVENTORY_FILE}" ]] && suggestions+=("${sibling}")
done
shopt -u nullglob
if ((${#suggestions[@]} > 0)); then
echo "Did you mean one of:" >&2
printf ' - %s\n' "${suggestions[@]}" >&2
fi
fi
exit 2
fi
if [[ ! -f "${pw_file}" ]]; then
echo "ERROR: password file not found: ${pw_file}" >&2
exit 2
fi
echo ">>> Running entry.sh"
./scripts/docker/entry.sh true
echo ">>> Starting rapid deploy"
# `--id` accepts multiple positional ids; split APPS on whitespace into a
# proper array instead of relying on shell word-splitting at expansion time
# (which shellcheck SC2206 rightly flags as fragile).
read -ra app_ids <<<"${APPS}"
cmd=(infinito administration deploy dedicated "${INVENTORY_FILE}"
--skip-backup
--skip-cleanup
--id "${app_ids[@]}"
-l localhost
--diff
-vv
--password-file "${pw_file}"
-e ASYNC_ENABLED=false
-e SYS_SERVICE_ALL_ENABLED=false
-e SYS_SERVICE_DEFAULT_STATE=started
)
if [[ "${DEBUG}" == "true" ]]; then
cmd+=(--debug)
fi
exec "${cmd[@]}"