2025-11-15 12:59:20 +01:00
|
|
|
---
|
2025-11-15 17:22:21 +01:00
|
|
|
###############################################################################
|
|
|
|
|
# Ansible Role: Proxmox Debian VM Template & Clone Manager
|
|
|
|
|
# defaults/main.yml - Default variables with comprehensive documentation
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
# BASE VM CONFIGURATION
|
|
|
|
|
###############################################################################
|
|
|
|
|
# Virtual Machine ID (must be unique, >= 100)
|
2025-11-15 09:51:38 +01:00
|
|
|
vm_id: 150
|
2025-11-15 17:22:21 +01:00
|
|
|
|
|
|
|
|
# Hostname for the base VM (template)
|
2025-11-15 09:51:38 +01:00
|
|
|
hostname: debian-template-base
|
|
|
|
|
|
2025-11-15 17:22:21 +01:00
|
|
|
# Memory in MB
|
2025-11-15 09:51:38 +01:00
|
|
|
memory: 4096
|
2025-11-15 17:22:21 +01:00
|
|
|
|
|
|
|
|
# Number of CPU cores
|
2025-11-15 09:51:38 +01:00
|
|
|
cores: 4
|
2025-11-15 17:22:21 +01:00
|
|
|
|
|
|
|
|
# CPU type (host, kvm64, x86-64-v2-AES, etc.)
|
|
|
|
|
cpu_type: host
|
|
|
|
|
|
|
|
|
|
# Bridge interface for networking
|
2025-11-15 09:51:38 +01:00
|
|
|
bridge: vmbr0
|
2025-11-15 17:22:21 +01:00
|
|
|
|
|
|
|
|
# Proxmox storage pool for VM disks
|
2025-11-15 09:51:38 +01:00
|
|
|
storage: local-lvm
|
|
|
|
|
|
2025-11-15 17:22:21 +01:00
|
|
|
###############################################################################
|
|
|
|
|
# MAC ADDRESS GENERATION (avoids collisions)
|
|
|
|
|
###############################################################################
|
|
|
|
|
# Base MAC address
|
2025-11-15 12:59:20 +01:00
|
|
|
mac_base: "DE:AD:BE"
|
2025-11-15 17:22:21 +01:00
|
|
|
|
|
|
|
|
# Auto-generate suffix based on VM ID
|
2025-11-15 12:59:20 +01:00
|
|
|
mac_suffix: "{{ '%02X:%02X' | format((vm_id // 256) % 256, vm_id % 256) }}"
|
2025-11-15 17:22:21 +01:00
|
|
|
|
|
|
|
|
# Full MAC address
|
2025-11-15 12:59:20 +01:00
|
|
|
mac_address: "{{ mac_base }}:{{ mac_suffix }}"
|
2025-11-15 09:51:38 +01:00
|
|
|
|
2025-11-15 17:22:21 +01:00
|
|
|
###############################################################################
|
|
|
|
|
# DEBIAN IMAGE CONFIGURATION
|
|
|
|
|
###############################################################################
|
|
|
|
|
# URL to Debian GenericCloud image
|
|
|
|
|
debian_image_url: "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2"
|
|
|
|
|
|
|
|
|
|
# Local path where image is cached
|
|
|
|
|
debian_image_path: "/var/lib/vz/template/qemu/debian-genericcloud-amd64.qcow2"
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
# NETWORKING CONFIGURATION
|
|
|
|
|
###############################################################################
|
|
|
|
|
# IP mode: "dhcp" or "static"
|
|
|
|
|
ip_mode: dhcp
|
|
|
|
|
|
|
|
|
|
# Static IP address (CIDR notation, only used if ip_mode: static)
|
2025-11-15 12:59:20 +01:00
|
|
|
ip_address: "192.168.1.60/24"
|
2025-11-15 17:22:21 +01:00
|
|
|
|
|
|
|
|
# Gateway IP address
|
2025-11-15 12:59:20 +01:00
|
|
|
gateway: "192.168.1.1"
|
2025-11-15 17:22:21 +01:00
|
|
|
|
|
|
|
|
# DNS nameservers
|
2025-11-15 12:59:20 +01:00
|
|
|
dns:
|
|
|
|
|
- "1.1.1.1"
|
|
|
|
|
- "8.8.8.8"
|
|
|
|
|
|
2025-11-15 17:22:21 +01:00
|
|
|
# Proxmox Cloud-Init network configuration
|
2025-11-15 12:59:20 +01:00
|
|
|
ipconfig0: "{{ 'ip=dhcp' if ip_mode == 'dhcp' else 'ip=' + ip_address + ',gw=' + gateway }}"
|
|
|
|
|
|
2025-11-15 17:22:21 +01:00
|
|
|
###############################################################################
|
|
|
|
|
# CLOUD-INIT CONFIGURATION
|
|
|
|
|
###############################################################################
|
|
|
|
|
# Default Cloud-Init user
|
2025-11-15 09:51:38 +01:00
|
|
|
ci_user: debian
|
2025-11-15 17:22:21 +01:00
|
|
|
|
|
|
|
|
# Default password for Cloud-Init user
|
|
|
|
|
# ⚠️ WARNING: Consider using Ansible Vault or external secrets management
|
|
|
|
|
# Example with vault: ci_password: "{{ vault_debian_password }}"
|
|
|
|
|
ci_password: "SecurePass123"
|
|
|
|
|
|
|
|
|
|
# Path to SSH public key (relative to ansible controller)
|
|
|
|
|
# This key will be added to authorized_keys for the ci_user
|
2025-11-15 09:51:38 +01:00
|
|
|
ssh_key_path: "~/.ssh/id_rsa.pub"
|
2025-11-15 17:22:21 +01:00
|
|
|
|
|
|
|
|
# Timezone for the VM
|
2025-11-15 12:59:20 +01:00
|
|
|
timezone: "Europe/Berlin"
|
2025-11-15 09:51:38 +01:00
|
|
|
|
2025-11-15 17:22:21 +01:00
|
|
|
###############################################################################
|
|
|
|
|
# PACKAGE MANAGEMENT
|
|
|
|
|
###############################################################################
|
|
|
|
|
# Packages to install via Cloud-Init
|
|
|
|
|
packages:
|
|
|
|
|
- qemu-guest-agent # Proxmox guest agent for better VM monitoring
|
|
|
|
|
- curl # Command-line HTTP client
|
|
|
|
|
- htop # Interactive process viewer
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
# DISK CONFIGURATION
|
|
|
|
|
###############################################################################
|
|
|
|
|
# Enable disk resizing after VM creation
|
2025-11-15 09:51:38 +01:00
|
|
|
resize_disk: true
|
2025-11-15 17:22:21 +01:00
|
|
|
|
|
|
|
|
# Target disk size (use 'G' for GB, 'T' for TB)
|
2025-11-15 09:51:38 +01:00
|
|
|
resize_size: "16G"
|
|
|
|
|
|
2025-11-15 17:22:21 +01:00
|
|
|
###############################################################################
|
|
|
|
|
# UEFI + TPM 2.0 CONFIGURATION (Advanced)
|
|
|
|
|
###############################################################################
|
|
|
|
|
# Enable UEFI firmware and TPM 2.0 support
|
|
|
|
|
# Required for: Secure Boot, Windows 11, modern security features
|
|
|
|
|
enable_tpm: false
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
# GPU PASSTHROUGH (Advanced)
|
|
|
|
|
###############################################################################
|
|
|
|
|
# Enable PCI GPU passthrough
|
|
|
|
|
# Requires: IOMMU support in host kernel (intel_iommu or amd_iommu)
|
2025-11-15 09:51:38 +01:00
|
|
|
gpu_passthrough: false
|
2025-11-15 17:22:21 +01:00
|
|
|
|
|
|
|
|
# PCI device ID of GPU to passthrough (format: DDDD:BB:SS.F)
|
|
|
|
|
# Find with: lspci | grep -i gpu
|
2025-11-15 09:51:38 +01:00
|
|
|
gpu_device: "0000:01:00.0"
|
|
|
|
|
|
2025-11-15 17:22:21 +01:00
|
|
|
# Use VirtIO GPU instead (software GPU emulation)
|
|
|
|
|
# Better compatibility, but lower performance than passthrough
|
|
|
|
|
virtio_gpu: false
|
2025-11-15 09:51:38 +01:00
|
|
|
|
2025-11-15 17:22:21 +01:00
|
|
|
###############################################################################
|
|
|
|
|
# TEMPLATE & CLONE CONFIGURATION
|
|
|
|
|
###############################################################################
|
|
|
|
|
# Convert base VM to a Proxmox template after configuration
|
|
|
|
|
# Templates cannot be booted directly but are faster to clone from
|
2025-11-15 09:51:38 +01:00
|
|
|
make_template: true
|
|
|
|
|
|
2025-11-15 17:22:21 +01:00
|
|
|
# Create clones from the template after conversion
|
2025-11-15 09:51:38 +01:00
|
|
|
create_clones: true
|
|
|
|
|
|
2025-11-15 17:22:21 +01:00
|
|
|
###############################################################################
|
|
|
|
|
# CLONE LIST
|
|
|
|
|
###############################################################################
|
|
|
|
|
# Each clone inherits the template's configuration and can override:
|
|
|
|
|
# id: unique Proxmox VM ID (>= 100, must not already exist)
|
|
|
|
|
# hostname: FQDN or hostname for the clone
|
|
|
|
|
# ip: IP address with CIDR (e.g., "192.168.1.81/24")
|
|
|
|
|
# gateway: Gateway IP for the clone
|
|
|
|
|
# full: 1 = full clone (independent, slow), 0 = linked clone (dependent, fast)
|
2025-11-15 09:51:38 +01:00
|
|
|
clones:
|
|
|
|
|
- id: 301
|
|
|
|
|
hostname: app01
|
|
|
|
|
ip: "192.168.1.81/24"
|
|
|
|
|
gateway: "192.168.1.1"
|
2025-11-15 12:59:20 +01:00
|
|
|
full: 1
|
2025-11-15 09:51:38 +01:00
|
|
|
- id: 302
|
|
|
|
|
hostname: app02
|
|
|
|
|
ip: "192.168.1.82/24"
|
|
|
|
|
gateway: "192.168.1.1"
|
2025-11-15 12:59:20 +01:00
|
|
|
full: 0
|
2025-11-15 17:22:21 +01:00
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
# ADVANCED OPTIONS
|
|
|
|
|
###############################################################################
|
|
|
|
|
# Enable verbose debug output (useful for troubleshooting)
|
|
|
|
|
debug_mode: false
|
|
|
|
|
|
|
|
|
|
# Retry configuration for transient failures
|
|
|
|
|
max_retries: 3
|
|
|
|
|
retry_delay: 5
|
|
|
|
|
|
|
|
|
|
# Timeout settings (in seconds)
|
|
|
|
|
image_download_timeout: 300
|
|
|
|
|
vm_boot_timeout: 60
|
|
|
|
|
cloud_init_timeout: 120
|