homelab/orchestration/ansible/scripts/create-ansible-control-vm.sh
Dan V deb6c38d7b chore: commit homelab setup — deployment, services, orchestration, skill
- 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>
2026-04-09 08:10:32 +02:00

48 lines
1.4 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
PROXMOX_HOST="${PROXMOX_HOST:-root@192.168.2.193}"
VMID="${VMID:-105}"
VM_NAME="${VM_NAME:-ansible-control}"
VM_CORES="${VM_CORES:-2}"
VM_MEMORY_MB="${VM_MEMORY_MB:-4096}"
VM_DISK_GB="${VM_DISK_GB:-40}"
VM_BRIDGE="${VM_BRIDGE:-vmbr0}"
VM_STORAGE="${VM_STORAGE:-local-lvm}"
ISO_STORAGE="${ISO_STORAGE:-local}"
ISO_FILE="${ISO_FILE:-ubuntu-24.04.4-live-server-amd64.iso}"
ssh -o StrictHostKeyChecking=no "${PROXMOX_HOST}" bash <<EOF
set -euo pipefail
if qm status "${VMID}" >/dev/null 2>&1; then
echo "VMID ${VMID} already exists; refusing to overwrite"
exit 1
fi
if [ ! -f "/var/lib/vz/template/iso/${ISO_FILE}" ]; then
echo "ISO /var/lib/vz/template/iso/${ISO_FILE} not found"
exit 1
fi
qm create "${VMID}" \
--name "${VM_NAME}" \
--ostype l26 \
--machine q35 \
--bios ovmf \
--cpu x86-64-v2-AES \
--cores "${VM_CORES}" \
--memory "${VM_MEMORY_MB}" \
--scsihw virtio-scsi-single \
--net0 virtio,bridge="${VM_BRIDGE}",firewall=1
qm set "${VMID}" --efidisk0 "${VM_STORAGE}:4,efitype=4m,pre-enrolled-keys=1"
qm set "${VMID}" --scsi0 "${VM_STORAGE}:${VM_DISK_GB},iothread=1"
qm set "${VMID}" --ide2 "${ISO_STORAGE}:iso/${ISO_FILE},media=cdrom"
qm set "${VMID}" --boot order=scsi0
qm set "${VMID}" --onboot 1
qm start "${VMID}"
echo "Created and started VM ${VMID} (${VM_NAME})."
echo "Complete Ubuntu install in console, then assign static IP 192.168.2.105 and user 'dan' SSH key auth."
EOF