- Add .gitignore: exclude compiled binaries, build artifacts, and Helm values files containing real secrets (authentik, prometheus) - Add all Kubernetes deployment manifests (deployment/) - Add services source code: ha-sync, device-inventory, games-console, paperclip, parts-inventory - Add Ansible orchestration: playbooks, roles, inventory, cloud-init - Add hardware specs, execution plans, scripts, HOMELAB.md - Add skills/homelab/SKILL.md + skills/install.sh to preserve Copilot skill - Remove previously-tracked inventory-cli binary from git index Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
33 lines
1.3 KiB
Django/Jinja
33 lines
1.3 KiB
Django/Jinja
#!/bin/sh
|
|
# Managed by Ansible — do not edit manually.
|
|
# Registers this host with the device-inventory server (idempotent),
|
|
# then runs a full hardware discovery and reports results back.
|
|
set -eu
|
|
|
|
HOST="{{ inventory_cli_server_host }}"
|
|
PORT="{{ inventory_cli_server_port }}"
|
|
NODE_NAME="{{ inventory_hostname }}"
|
|
NODE_IP="{{ ansible_default_ipv4.address }}"
|
|
DESCRIPTION="{{ inventory_cli_description }}"
|
|
|
|
echo "[inventory-cli] node=$NODE_NAME ip=$NODE_IP server=$HOST:$PORT"
|
|
|
|
# Check if server already registered (output format: "[N] name (hostname) loc: ...")
|
|
SERVER_ID=$(device-inventory --host "$HOST" --port "$PORT" list-servers 2>/dev/null \
|
|
| grep "^\[[0-9]*\] $NODE_NAME (" | grep -o '^\[[0-9]*\]' | tr -d '[]')
|
|
|
|
# Only register if not found
|
|
if [ -z "$SERVER_ID" ]; then
|
|
ADD_OUT=$(device-inventory --host "$HOST" --port "$PORT" \
|
|
add-server "$NODE_NAME" "$NODE_IP" "homelab" "$DESCRIPTION" 2>&1 || true)
|
|
SERVER_ID=$(echo "$ADD_OUT" | grep -o '^\[[0-9]*\]' | tr -d '[]')
|
|
fi
|
|
|
|
if [ -z "$SERVER_ID" ]; then
|
|
echo "[inventory-cli] ERROR: could not register or find server for $NODE_NAME" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "[inventory-cli] server_id=$SERVER_ID — running full hardware discovery"
|
|
device-inventory --host "$HOST" --port "$PORT" discover "$SERVER_ID"
|
|
echo "[inventory-cli] done"
|