homelab/scripts/onboarding.sh
nathan e16f98a183 feat(bootstrap)!: introduce unified bootstrap system with modular libraries
BREAKING CHANGE: day0bootstrap.sh deprecated in favor of bootstrap.sh

- Add scripts/bootstrap.sh (488 lines): Unified entrypoint supporting multiple hardware types (Proxmox/Docker VMs/Pi)
- Create scripts/lib/ modular library system:
  - detection.sh: OS/hardware/container detection (362 lines)
  - fingerprint.sh: System fingerprinting and inventory (494 lines)
  - network.sh: IP configuration and VLAN placement (356 lines)
  - proxmox.sh: PVE post-install automation (453 lines)
  - validation.sh: Comprehensive pre-flight checks (510 lines)
- Add validation tools: validate-node.sh, onboarding.sh, pi_init.sh
- Deprecate scripts/day0bootstrap.sh with graceful redirect wrapper
- Document architecture in scripts/README.md (495 lines) and PROXMOX-COMPARISON.md
- Update SOP-002 with new bootstrap workflow
- Add nodes/watchtower/compose.yaml (Raspberry Pi 5 stack)

Migration: Existing day0bootstrap.sh users automatically redirected to new system after 5-second warning. No manual intervention required.

Ref: Infrastructure automation modernization per active-tasks.md
2026-04-12 22:48:19 -04:00

85 lines
3.2 KiB
Bash

#!/bin/bash
# ==============================================================================
# DEPRECATED: onboarding.sh
# ==============================================================================
# ⚠️ DEPRECATION NOTICE
# This script is deprecated and will be removed in a future release.
# Please use the unified bootstrap.sh script instead:
#
# ./bootstrap.sh
#
# Note: Proxmox SSH key distribution is now handled by:
# 1. Run bootstrap.sh to generate keys
# 2. Manually copy keys to Proxmox: ssh-copy-id root@<proxmox-ip>
# 3. Run Ansible playbook: ansible-playbook playbooks/onboarding/proxmox_host.yml
#
# This wrapper will redirect to bootstrap.sh.
# ==============================================================================
set -euo pipefail
# Show deprecation warning
echo "=======================================" >&2
echo "⚠️ DEPRECATION WARNING" >&2
echo "=======================================" >&2
echo "onboarding.sh is deprecated!" >&2
echo "" >&2
echo "Please use: ./bootstrap.sh" >&2
echo "" >&2
echo "Note: Proxmox SSH key setup is now a separate step." >&2
echo "See documentation/SOPs/SOP-002-Initial-Infrastructure-Deployment.md" >&2
echo "" >&2
echo "Redirecting to bootstrap.sh in 5 seconds..." >&2
echo "Press Ctrl+C to cancel" >&2
echo "=======================================" >&2
sleep 5
# Redirect to unified bootstrap
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
exec "${SCRIPT_DIR}/bootstrap.sh" "$@"
# ==============================================================================
# LEGACY CODE BELOW (no longer executed)
# ==============================================================================
# ENVIRONMENT VARIABLES
# ==============================================================================
PROXMOX_IP="192.168.1.100" # <--- CHANGE ME
PROXMOX_USER="root" # <--- CHANGE ME
# ==============================================================================
echo "--- Starting Lead Architect Bootstrap Process ---"
# 1. Install Ansible and dependencies
echo "[1/4] Installing Ansible and Proxmoxer..."
sudo apt update && sudo apt install -y ansible python3-pip
pip3 install proxmoxer --break-system-packages 2>/dev/null || pip3 install proxmoxer
# 2. Smart SSH Key Check
# We check for ED25519 first, then RSA.
if [ -f "$HOME/.ssh/id_ed25519" ]; then
SSH_KEY_PATH="$HOME/.ssh/id_ed25519"
echo "[2/4] Found existing ED25519 key at $SSH_KEY_PATH"
elif [ -f "$HOME/.ssh/id_rsa" ]; then
SSH_KEY_PATH="$HOME/.ssh/id_rsa"
echo "[2/4] Found existing RSA key at $SSH_KEY_PATH. Using as fallback."
else
SSH_KEY_PATH="$HOME/.ssh/id_ed25519"
echo "[2/4] No usable keys found. Generating new ED25519 keypair..."
ssh-keygen -t ed25519 -f "$SSH_KEY_PATH" -N ""
fi
# 3. Transfer Public Key
# We use the variable determined in the step above
echo "[3/4] Copying ${SSH_KEY_PATH}.pub to Proxmox ($PROXMOX_IP)..."
ssh-copy-id -i "${SSH_KEY_PATH}.pub" "${PROXMOX_USER}@${PROXMOX_IP}"
# 4. Create Inventory
echo "[4/4] Generating hosts.ini..."
cat <<EOF > hosts.ini
[proxmox_nodes]
proxmox_server ansible_host=$PROXMOX_IP ansible_user=$PROXMOX_USER ansible_ssh_private_key_file=$SSH_KEY_PATH
EOF
echo "--- Bootstrap Complete ---"
echo "Verification: ansible proxmox_nodes -m ping -i hosts.ini"