mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-08 11:46:35 +00:00
Renames the three in-container deploy helpers out of `utils/` (where
they lived next to unrelated bash libs) into a `container/` subtree
that mirrors the host-side `apps/` layout one-to-one:
utils/fresh-kept-all-init-and-deploy.sh -> container/initialize/all.sh
utils/reuse-kept-all-deploy.sh -> container/update/all.sh
utils/reuse-kept-app-deploy.sh -> container/update/selection.sh
The `fresh-/reuse-/kept-` prefixes were overloaded ("kept" was
universal, "fresh/reuse" duplicated the verb already encoded in
initialize/update). New names use the same verbs + scope as the host
wrappers, so the host/container halves of each flow share a name.
Updates the three host wrappers under apps/{initialize,update}/ to
point at the new in-container paths and modernizes their
cache-retry keys (`fresh-kept-all` -> `initialize-all`, `reuse-all` ->
`update-all`, `reuse-<app>` -> `update-<app>`).
Adds READMEs for container/, container/initialize/, container/update/
following the project documentation conventions (H1 + trailing emoji,
RFC 2119 keywords, env-var tables, cross-links to the matching host
wrappers) and extends deploy/README.md with a pointer to the new
subtree.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
110 lines
3.5 KiB
Bash
Executable File
110 lines
3.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Initialize a local inventory for ALL discovered apps.
|
|
#
|
|
# Required:
|
|
# INFINITO_DISTRO (arch|debian|ubuntu|fedora|centos)
|
|
# INFINITO_DEPLOY_TYPE (server|workstation|universal)
|
|
# INFINITO_INVENTORY_DIR (e.g. /etc/inventories/local-full-server)
|
|
|
|
: "${INFINITO_DISTRO:?INFINITO_DISTRO must be set (arch|debian|ubuntu|fedora|centos)}"
|
|
: "${INFINITO_DEPLOY_TYPE:?INFINITO_DEPLOY_TYPE must be set (server|workstation|universal)}"
|
|
: "${INFINITO_INVENTORY_DIR:?INFINITO_INVENTORY_DIR must be set (e.g. /etc/inventories/local-full-server)}"
|
|
: "${INFINITO_INVENTORY_FILE:?INFINITO_INVENTORY_FILE is not set — source scripts/meta/env/load.sh first}"
|
|
: "${INFINITO_INVENTORY_VARS_FILE:?INFINITO_INVENTORY_VARS_FILE is not set — source scripts/meta/env/load.sh first}"
|
|
|
|
# This script always generates inventories for the development compose stack.
|
|
RUNTIME_VARS_JSON='{"RUNTIME":"dev","SYS_SERVICE_RUNNER_RETRIES":1}'
|
|
|
|
echo "=== local inventory init (ALL apps) ==="
|
|
echo "distro = ${INFINITO_DISTRO}"
|
|
echo "type = ${INFINITO_DEPLOY_TYPE}"
|
|
echo "inventory_dir = ${INFINITO_INVENTORY_DIR}"
|
|
echo
|
|
|
|
# 1) Bring up development stack (no build)
|
|
echo ">>> Starting development compose stack (no build)"
|
|
"${PYTHON}" -m cli.administration.deploy.development up \
|
|
--skip-entry-init
|
|
|
|
# 2) Discover apps on HOST (same as local/deploy/apps/initialize/all.sh)
|
|
apps_json="$(
|
|
INFINITO_DEPLOY_TYPE="${INFINITO_DEPLOY_TYPE}" \
|
|
INFINITO_WHITELIST="${INFINITO_WHITELIST:-}" \
|
|
PYTHON=python3 \
|
|
scripts/meta/resolve/apps.sh
|
|
)"
|
|
|
|
if [[ -z "${apps_json}" ]]; then
|
|
echo "ERROR: app matrix is empty" >&2
|
|
exit 2
|
|
fi
|
|
|
|
apps_count="$(
|
|
"${PYTHON}" -c 'import json,sys; a=json.loads(sys.argv[1]); assert isinstance(a,list); print(len(a))' \
|
|
"${apps_json}"
|
|
)"
|
|
|
|
if [[ "${apps_count}" == "0" ]]; then
|
|
echo "ERROR: discovered apps list has length 0" >&2
|
|
echo "apps_json=${apps_json}" >&2
|
|
exit 2
|
|
fi
|
|
|
|
apps_csv="$(
|
|
"${PYTHON}" -c 'import json,sys; a=json.loads(sys.argv[1]); print(",".join(map(str,a)))' \
|
|
"${apps_json}"
|
|
)"
|
|
|
|
if [[ -z "${apps_csv}" ]]; then
|
|
echo "ERROR: apps_csv ended up empty even though apps_count=${apps_count}" >&2
|
|
exit 2
|
|
fi
|
|
|
|
echo "apps_count=${apps_count}"
|
|
echo "apps_sample=$(
|
|
"${PYTHON}" -c 'import json,sys; a=json.loads(sys.argv[1]); print(",".join(a[:8]) + ("..." if len(a)>8 else ""))' \
|
|
"${apps_json}"
|
|
)"
|
|
echo
|
|
|
|
# 3) Run entry.sh + create inventory INSIDE container
|
|
echo ">>> Initializing inventory inside container"
|
|
|
|
"${PYTHON}" -m cli.administration.deploy.development exec \
|
|
-- \
|
|
bash -c "
|
|
set -euo pipefail
|
|
cd \"${INFINITO_SRC_DIR}\"
|
|
|
|
echo '>>> entry.sh bootstrap'
|
|
./scripts/docker/entry.sh true
|
|
|
|
inv_dir='${INFINITO_INVENTORY_DIR}'
|
|
INFINITO_INVENTORY_FILE='${INFINITO_INVENTORY_FILE}'
|
|
pw_file=\"\${inv_dir}/.password\"
|
|
echo \">>> Reset inventory dir \${inv_dir}\"
|
|
rm -rf \"\${inv_dir}\"
|
|
mkdir -p \"\${inv_dir}\"
|
|
|
|
if [[ ! -f \"\${pw_file}\" ]]; then
|
|
printf '%s\n' 'local-vault-password' > \"\${pw_file}\"
|
|
chmod 600 \"\${pw_file}\" || true
|
|
fi
|
|
|
|
echo \">>> Creating inventory at \${INFINITO_INVENTORY_FILE}\"
|
|
infinito administration inventory provision \"\${inv_dir}\" \
|
|
--inventory-file \"\${INFINITO_INVENTORY_FILE}\" \
|
|
--vars '${RUNTIME_VARS_JSON}' \
|
|
--host 'localhost' \
|
|
--vars-file '${INFINITO_INVENTORY_VARS_FILE}' \
|
|
--include '${apps_csv}'
|
|
|
|
echo '✅ Inventory initialized.'
|
|
"
|
|
|
|
echo
|
|
echo "✅ Local inventory init finished."
|
|
echo "Inventory: ${INFINITO_INVENTORY_FILE}"
|