claude-home/scripts/vm-management/cloud-init-user-data.yaml
Cal Corum 7edb4a3a9c CLAUDE: Update VM management patterns and Tdarr operational scripts
- Update patterns/vm-management/README.md: Add comprehensive automation workflows
  - Cloud-init deployment strategies and post-install automation
  - SSH key management integration and security hardening patterns
  - Implementation workflows for new and existing VM provisioning

- Add complete VM management examples and reference documentation
  - examples/vm-management/: Proxmox automation and provisioning examples
  - reference/vm-management/: Troubleshooting guides and best practices
  - scripts/vm-management/: Operational scripts for automated VM setup

- Update reference/docker/tdarr-monitoring-configuration.md: API monitoring integration
  - Document new tdarr_monitor.py integration with existing Discord monitoring
  - Add API-based health checks and cron scheduling examples
  - Enhanced gaming scheduler integration with health verification

- Update Tdarr operational scripts with stability improvements
  - scripts/tdarr/start-tdarr-gpu-podman-clean.sh: Resource limits and CDI GPU access
  - scripts/tdarr/tdarr-schedule-manager.sh: Updated container name references
  - scripts/monitoring/tdarr-timeout-monitor.sh: Enhanced completion monitoring

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-12 12:18:43 -05:00

154 lines
6.1 KiB
YAML

#cloud-config
#
# Proxmox Cloud-Init User Data Template
# Use this as the user data for VM provisioning in Proxmox
# This automates: updates, SSH keys, Docker installation, security hardening
#
# System configuration
hostname: homelab-vm
timezone: America/New_York
locale: en_US.UTF-8
# User configuration
users:
- name: cal
groups: [sudo, docker]
shell: /bin/bash
sudo: ALL=(ALL) NOPASSWD:ALL
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDVVK02rOeeIw1e7BkGlUtSCVrO66dcYM6wGC6snL/lDSxRWi3ABinOj7a74SJ12uuBjpj1Ui6fGbYLvLHCzrMQaijOKpno4BQmulVLT2hKw6xBszQlA7Z2NpP/CiieUsCYBj+vfn743grLRkb6jgVEw2E3TCkNOord0zfmPp6EIre7clUuPUlP75IZMpttbqXhOTjn8Kfq+8+a/iHln4LLDBJbaz/J31Wxnk+eI5tdVz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e1biJK+jSPYIr+qXdzvvLrrSG/ajg+9flc8HHhEs/A5EAm2naRR739xvKOIQboRsV67UgZ4TH1aJZNzQEkA70qGSGsZNPtVsbzS/4YlHH9CPawnv3ICQ== emergency-homelab-cal@nobara-pc
# SSH configuration
ssh_pwauth: false
disable_root: true
ssh_genkeytypes: []
# Package management
package_update: true
package_upgrade: true
package_reboot_if_required: true
packages:
- curl
- wget
- git
- vim
- htop
- unzip
- software-properties-common
- apt-transport-https
- ca-certificates
- gnupg
- lsb-release
- unattended-upgrades
# Docker installation via runcmd
runcmd:
# Configure automatic security updates
- dpkg-reconfigure -plow unattended-upgrades
# Remove any old Docker installations
- apt-get remove -y docker docker-engine docker.io containerd runc || true
# Add Docker GPG key and repository
- mkdir -p /etc/apt/keyrings
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
- echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker
- apt-get update
- apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Enable Docker service
- systemctl enable docker
- systemctl start docker
# Add cal user to docker group (will take effect after next login)
- usermod -aG docker cal
# Test Docker installation
- docker run --rm hello-world
# Write configuration files
write_files:
# SSH hardening configuration
- path: /etc/ssh/sshd_config.d/99-homelab-security.conf
content: |
PasswordAuthentication no
PubkeyAuthentication yes
PermitRootLogin no
AllowUsers cal
Protocol 2
ClientAliveInterval 300
ClientAliveCountMax 2
MaxAuthTries 3
permissions: '0644'
# Useful bash aliases for the cal user
- path: /home/cal/.bash_aliases
content: |
# Docker aliases
alias dps='docker ps'
alias dlog='docker logs'
alias dexec='docker exec -it'
alias dstop='docker stop $(docker ps -q)'
alias dprune='docker system prune -f'
# Docker Compose aliases
alias dc='docker compose'
alias dcup='docker compose up -d'
alias dcdown='docker compose down'
alias dclogs='docker compose logs -f'
# System aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias ..='cd ..'
alias ...='cd ../..'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
owner: cal:cal
permissions: '0644'
# Welcome message with system info
- path: /etc/motd
content: |
╔══════════════════════════════════════════════════════╗
║ Home Lab VM - Ready ║
║ ║
║ Docker & Docker Compose: Installed ✓ ║
║ SSH Keys: Deployed ✓ ║
║ Security: Hardened ✓ ║
║ Updates: Automatic ✓ ║
║ ║
║ Quick Commands: ║
║ docker --version ║
║ docker compose version ║
║ docker run --rm hello-world ║
║ ║
╚══════════════════════════════════════════════════════╝
permissions: '0644'
# Final commands to run after everything else
final_message: |
VM provisioning completed successfully!
Installed software:
- Docker & Docker Compose
- Essential system packages
- Automatic security updates
Security configuration:
- SSH key-based authentication only
- Password authentication disabled
- User 'cal' added to docker group
Connect via SSH: ssh cal@<vm-ip>
System is ready for Docker container deployment!