mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-09 20:26:33 +00:00
Module moves (with imports, paths, argv literals, scripts, docs, and
parents[N] formulas updated in lockstep):
- cli/deploy -> cli/administration/deploy
- cli/validate/inventory -> cli/administration/inventory/validate
- cli/vault -> cli/administration/secrets/vault
- cli/administration/inventory/encrypt -> cli/administration/secrets/seal
- cli/mirror -> cli/contributing/mirror
The new cli/administration/secrets cluster collocates the whole-file
ansible-vault wrapper next to the inventory-aware per-field sealer.
The user-facing CLI subcommand paths follow the package layout, e.g.
"infinito administration deploy dedicated <inv>" and
"infinito administration inventory validate <inv>".
Help system redesign in cli/core/{discovery,help,app}.py:
- Discovery now distinguishes runnable commands (directories with
__main__.py) from category folders (directories that only group
further commands). Empty support packages are filtered out.
- Each category folder MAY carry a README.md; its H1 heading is used
as the title and its first paragraph as the one-line description in
the help output.
- "infinito" / "infinito --help" prints only the top-level entries
(one level deep). "infinito <category>" navigates into a folder and
shows its sub-folders and commands one level deep, with the README
title as the page heading and the invocation as a dim subtitle.
- New "--tree [N]" flag walks the tree under the (optional) path
prefix recursively. N caps the depth (1-based); omit N for an
unbounded walk. The output uses Unicode tree connectors, an emoji
per entry (folder for categories, gear for commands), a globally
aligned description column, and multi-line wrapped descriptions
with tree-continuity bars on continuation lines.
- Category and command listings use the full invocation
("infinito meta callorder") rather than the bare leaf name, so the
output is copy-pasteable.
Convention doc + 17 CLI READMEs:
- New docs/contributing/artefact/files/cli/readme_md.md describes the
H1+paragraph layout the help system reads, and how it differs from
role/docs READMEs.
- README.md added for cli/{administration, build, contributing, meta}
and their immediate sub-folders, plus cli/meta/roles/applications
and its resolution sub-folder. Each follows the "title with trailing
emoji + single descriptive paragraph" convention.
Mirror resolver/sync description strings (the help system reads them
from argparse --help output) added so they no longer surface as
"options:" in the global index. cli/mirror/cleanup already had a
description and is unchanged.
Fixes uncovered by the move:
- import unittest.mock added to four dedicated-deploy tests so
unittest.mock.patch resolves under stdlib unittest discovery
(Python 3.13 no longer surfaces unittest.mock through "import
unittest" alone).
- parents[N] index in the new
cli/administration/inventory/validate/__init__.py corrected from
3 to 4 to match the deeper layout.
- test_paths.INVENTORY_VALIDATOR_PATH assertion and test_runner
substring assertions updated to match the new validator path.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
111 lines
3.3 KiB
Bash
Executable File
111 lines
3.3 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)
|
|
# TEST_DEPLOY_TYPE (server|workstation|universal)
|
|
# INVENTORY_DIR (e.g. /etc/inventories/local-full-server)
|
|
|
|
: "${INFINITO_DISTRO:?INFINITO_DISTRO must be set (arch|debian|ubuntu|fedora|centos)}"
|
|
: "${TEST_DEPLOY_TYPE:?TEST_DEPLOY_TYPE must be set (server|workstation|universal)}"
|
|
: "${INVENTORY_DIR:?INVENTORY_DIR must be set (e.g. /etc/inventories/local-full-server)}"
|
|
: "${INVENTORY_FILE:?INVENTORY_FILE is not set — source scripts/meta/env/inventory.sh first}"
|
|
: "${INVENTORY_VARS_FILE:?INVENTORY_VARS_FILE is not set — source scripts/meta/env/inventory.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 = ${TEST_DEPLOY_TYPE}"
|
|
echo "inventory_dir = ${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/fresh-kept-all.sh)
|
|
apps_json="$(
|
|
TEST_DEPLOY_TYPE="${TEST_DEPLOY_TYPE}" \
|
|
WHITELIST="${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 /opt/src/infinito
|
|
|
|
echo '>>> entry.sh bootstrap'
|
|
./scripts/docker/entry.sh true
|
|
|
|
inv_dir='${INVENTORY_DIR}'
|
|
INVENTORY_FILE='${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 \${INVENTORY_FILE}\"
|
|
infinito administration inventory provision \"\${inv_dir}\" \
|
|
--inventory-file \"\${INVENTORY_FILE}\" \
|
|
--vars '${RUNTIME_VARS_JSON}' \
|
|
--host 'localhost' \
|
|
--ssl-disabled \
|
|
--vars-file '${INVENTORY_VARS_FILE}' \
|
|
--include '${apps_csv}'
|
|
|
|
echo '✅ Inventory initialized.'
|
|
"
|
|
|
|
echo
|
|
echo "✅ Local inventory init finished."
|
|
echo "Inventory: ${INVENTORY_FILE}"
|