2025-11-15 14:34:58 +01:00
|
|
|
|
# Ansible Role: Proxmox VM → Template → Clones (Cloud‑Init)
|
|
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
**Production-grade automation** for Debian GenericCloud VMs on Proxmox with error handling, idempotency, and comprehensive validation.
|
|
|
|
|
|
|
|
|
|
|
|
Automates the complete lifecycle:
|
|
|
|
|
|
- ✅ Pre-flight environment validation (20+ checks)
|
|
|
|
|
|
- ✅ Download & cache Debian GenericCloud image
|
|
|
|
|
|
- ✅ Create base VM with error recovery
|
|
|
|
|
|
- ✅ Configure disk, networking, Cloud-Init, TPM, GPU
|
|
|
|
|
|
- ✅ Convert VM to template (**idempotent** - safe to re-run!)
|
|
|
|
|
|
- ✅ Deploy multiple clones with custom networking
|
|
|
|
|
|
- ✅ Per-clone error handling (failures don't cascade)
|
2025-11-15 14:34:58 +01:00
|
|
|
|
|
|
|
|
|
|
## Features
|
|
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
- ✅ **Error Handling** - Automatic retry (3x, 5-sec delay) with clear messages
|
|
|
|
|
|
- ✅ **Idempotency** - Truly safe to re-run; skips already-completed operations
|
2025-11-16 08:42:26 +01:00
|
|
|
|
- ✅ **Modular Design** - Helper functions encapsulate common VM operations
|
2025-11-15 17:39:23 +01:00
|
|
|
|
- ✅ **Pre-flight Validation** - 20+ environment checks before execution
|
|
|
|
|
|
- ✅ **Image Caching** - Downloads once, reuses on re-runs (faster!)
|
|
|
|
|
|
- ✅ **DHCP or Static IP** - Flexible networking configuration
|
|
|
|
|
|
- ✅ **Cloud-Init** - Users, SSH keys, passwords, timezone, packages
|
|
|
|
|
|
- ✅ **TPM 2.0 + SecureBoot** - Optional UEFI firmware support
|
|
|
|
|
|
- ✅ **GPU Passthrough** - Optional PCI device or VirtIO GPU
|
|
|
|
|
|
- ✅ **Disk Resize** - Optional automatic disk expansion
|
2025-11-16 08:42:26 +01:00
|
|
|
|
- ✅ **Multi-Clone** - Deploy multiple clones independently with per-clone error handling
|
2025-11-15 17:39:23 +01:00
|
|
|
|
- ✅ **Rich Logging** - Progress tracking and debug output
|
2025-11-15 14:34:58 +01:00
|
|
|
|
|
|
|
|
|
|
## Folder Structure
|
|
|
|
|
|
|
|
|
|
|
|
```
|
2025-11-15 17:39:23 +01:00
|
|
|
|
ansible_proxmox_VM/
|
2025-11-15 14:34:58 +01:00
|
|
|
|
├─ defaults/
|
2025-11-15 17:39:23 +01:00
|
|
|
|
│ └─ main.yml # All configuration (comprehensive docs)
|
2025-11-15 14:34:58 +01:00
|
|
|
|
├─ tasks/
|
2025-11-15 17:39:23 +01:00
|
|
|
|
│ ├─ main.yml # Orchestrator (calls subtasks)
|
|
|
|
|
|
│ ├─ preflight-checks.yml # Environment validation (20+ checks)
|
|
|
|
|
|
│ ├─ download-image.yml # Download Debian image (with caching)
|
|
|
|
|
|
│ ├─ create-vm.yml # Create VM (idempotent)
|
|
|
|
|
|
│ ├─ configure-vm.yml # Configure disk, Cloud-Init, TPM, GPU
|
|
|
|
|
|
│ ├─ create-template.yml # Convert to template (idempotent - FIXED!)
|
|
|
|
|
|
│ ├─ create-clones.yml # Deploy clones (per-clone error handling)
|
|
|
|
|
|
│ └─ helpers.yml # 8 utility functions
|
2025-11-15 14:34:58 +01:00
|
|
|
|
├─ templates/
|
2025-11-15 17:39:23 +01:00
|
|
|
|
│ ├─ cloudinit_userdata.yaml.j2 # Cloud-Init user data template
|
|
|
|
|
|
│ └─ cloudinit_vendor.yaml.j2 # Cloud-Init vendor data template
|
|
|
|
|
|
└─ README.md # This file
|
2025-11-15 14:34:58 +01:00
|
|
|
|
```
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 14:34:58 +01:00
|
|
|
|
## Requirements
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
- **Proxmox VE** 7.x or 8.x installed and accessible
|
|
|
|
|
|
- **Ansible** 2.9+ with SSH access to Proxmox host
|
|
|
|
|
|
- **Proxmox user** with permission to run `qm` commands (root recommended)
|
|
|
|
|
|
- **Storage pool** configured (e.g., `local-lvm`)
|
|
|
|
|
|
- **Snippets storage** enabled for Cloud-Init (`Datacenter → Storage`)
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 17:37:15 +01:00
|
|
|
|
## Quick Start
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 17:37:15 +01:00
|
|
|
|
### 1. Validate Environment
|
|
|
|
|
|
```bash
|
|
|
|
|
|
ansible-playbook tasks/main.yml --tags preflight -vvv
|
|
|
|
|
|
```
|
2025-11-15 17:39:23 +01:00
|
|
|
|
Checks Proxmox connectivity, storage, SSH keys, permissions.
|
2025-11-15 17:37:15 +01:00
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
### 2. Dry Run (Preview Changes)
|
2025-11-15 17:37:15 +01:00
|
|
|
|
```bash
|
|
|
|
|
|
ansible-playbook tasks/main.yml --check -vv
|
|
|
|
|
|
```
|
2025-11-15 17:39:23 +01:00
|
|
|
|
Shows what would happen without making any changes.
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 17:37:15 +01:00
|
|
|
|
### 3. Full Deployment
|
|
|
|
|
|
```bash
|
|
|
|
|
|
ansible-playbook tasks/main.yml -i inventory
|
2025-11-15 14:34:58 +01:00
|
|
|
|
```
|
2025-11-15 17:39:23 +01:00
|
|
|
|
Creates VM → configures it → converts to template → deploys clones
|
2025-11-15 17:37:15 +01:00
|
|
|
|
|
|
|
|
|
|
### 4. Re-run (Test Idempotency)
|
|
|
|
|
|
```bash
|
|
|
|
|
|
ansible-playbook tasks/main.yml -i inventory
|
2025-11-15 14:34:58 +01:00
|
|
|
|
```
|
2025-11-15 17:39:23 +01:00
|
|
|
|
Second run is much faster (~30 sec)! Skips already-completed operations.
|
2025-11-15 14:34:58 +01:00
|
|
|
|
|
2025-11-15 17:37:15 +01:00
|
|
|
|
## Configuration Variables
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
All variables are in `defaults/main.yml` with comprehensive inline documentation.
|
2025-11-15 17:37:15 +01:00
|
|
|
|
|
|
|
|
|
|
### Base VM Configuration
|
2025-11-15 14:34:58 +01:00
|
|
|
|
```yaml
|
2025-11-15 17:37:15 +01:00
|
|
|
|
vm_id: 150 # Unique Proxmox VM ID (≥100)
|
|
|
|
|
|
hostname: debian-template-base # VM hostname
|
|
|
|
|
|
memory: 4096 # RAM in MB
|
|
|
|
|
|
cores: 4 # CPU cores
|
2025-11-15 17:39:23 +01:00
|
|
|
|
cpu_type: host # CPU type
|
2025-11-15 17:37:15 +01:00
|
|
|
|
bridge: vmbr0 # Network bridge
|
|
|
|
|
|
storage: local-lvm # Storage pool
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### Networking
|
|
|
|
|
|
```yaml
|
|
|
|
|
|
ip_mode: dhcp # 'dhcp' or 'static'
|
2025-11-15 17:39:23 +01:00
|
|
|
|
ip_address: "192.168.1.60/24" # Static IP if ip_mode: static
|
|
|
|
|
|
gateway: "192.168.1.1" # Gateway
|
2025-11-15 12:58:55 +01:00
|
|
|
|
dns:
|
|
|
|
|
|
- "1.1.1.1"
|
2025-11-15 17:39:23 +01:00
|
|
|
|
- "8.8.8.8"
|
2025-11-15 17:37:15 +01:00
|
|
|
|
```
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 17:37:15 +01:00
|
|
|
|
### Cloud-Init
|
|
|
|
|
|
```yaml
|
|
|
|
|
|
ci_user: debian # Default user
|
2025-11-15 17:39:23 +01:00
|
|
|
|
ci_password: "SecurePass123" # Use Vault in production!
|
|
|
|
|
|
ssh_key_path: "~/.ssh/id_rsa.pub" # SSH public key path
|
2025-11-15 17:37:15 +01:00
|
|
|
|
timezone: "Europe/Berlin" # Timezone
|
|
|
|
|
|
packages:
|
|
|
|
|
|
- qemu-guest-agent
|
|
|
|
|
|
- curl
|
|
|
|
|
|
- htop
|
|
|
|
|
|
```
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 17:37:15 +01:00
|
|
|
|
### Advanced Options
|
|
|
|
|
|
```yaml
|
2025-11-15 17:39:23 +01:00
|
|
|
|
enable_tpm: false # UEFI + TPM 2.0
|
|
|
|
|
|
gpu_passthrough: false # PCI GPU passthrough
|
|
|
|
|
|
virtio_gpu: false # VirtIO GPU
|
|
|
|
|
|
resize_disk: true # Auto-resize disk
|
|
|
|
|
|
resize_size: "16G" # Target disk size
|
|
|
|
|
|
make_template: true # Convert to template
|
|
|
|
|
|
create_clones: true # Deploy clones
|
2025-11-15 17:37:15 +01:00
|
|
|
|
```
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 17:37:15 +01:00
|
|
|
|
### Clone Definition
|
|
|
|
|
|
```yaml
|
2025-11-15 12:58:55 +01:00
|
|
|
|
clones:
|
2025-11-15 17:39:23 +01:00
|
|
|
|
- id: 301
|
|
|
|
|
|
hostname: app01
|
|
|
|
|
|
ip: "192.168.1.81/24"
|
2025-11-15 17:37:15 +01:00
|
|
|
|
gateway: "192.168.1.1"
|
2025-11-15 17:39:23 +01:00
|
|
|
|
full: 1 # 1=full, 0=linked
|
2025-11-15 17:37:15 +01:00
|
|
|
|
- id: 302
|
|
|
|
|
|
hostname: app02
|
|
|
|
|
|
ip: "192.168.1.82/24"
|
2025-11-15 12:58:55 +01:00
|
|
|
|
gateway: "192.168.1.1"
|
2025-11-15 17:39:23 +01:00
|
|
|
|
full: 0 # Linked clones are faster
|
2025-11-15 14:34:58 +01:00
|
|
|
|
```
|
|
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
See `defaults/main.yml` for all options with detailed documentation.
|
2025-11-15 14:34:58 +01:00
|
|
|
|
|
2025-11-15 17:37:15 +01:00
|
|
|
|
## Usage
|
|
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
### Include in Playbook
|
2025-11-15 14:34:58 +01:00
|
|
|
|
```yaml
|
2025-11-15 17:37:15 +01:00
|
|
|
|
- hosts: proxmox_host
|
2025-11-15 12:58:55 +01:00
|
|
|
|
become: true
|
|
|
|
|
|
roles:
|
2025-11-15 17:37:15 +01:00
|
|
|
|
- ansible_proxmox_vm
|
2025-11-15 14:34:58 +01:00
|
|
|
|
```
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
### Run Directly
|
2025-11-15 14:34:58 +01:00
|
|
|
|
```bash
|
2025-11-15 12:58:55 +01:00
|
|
|
|
ansible-playbook tasks/main.yml -i inventory
|
2025-11-15 14:34:58 +01:00
|
|
|
|
```
|
|
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
### Using Tags (Run Specific Stages)
|
2025-11-15 17:37:15 +01:00
|
|
|
|
```bash
|
|
|
|
|
|
# Pre-flight checks only
|
|
|
|
|
|
ansible-playbook tasks/main.yml --tags preflight -vvv
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 17:37:15 +01:00
|
|
|
|
# Create VM and template (skip clones)
|
|
|
|
|
|
ansible-playbook tasks/main.yml --skip-tags clones
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 17:37:15 +01:00
|
|
|
|
# Add clones to existing template
|
|
|
|
|
|
ansible-playbook tasks/main.yml --tags clones
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
# Skip image re-download
|
2025-11-15 17:37:15 +01:00
|
|
|
|
ansible-playbook tasks/main.yml --skip-tags image
|
|
|
|
|
|
```
|
2025-11-15 14:34:58 +01:00
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
## Playbook Stages (6 Stages)
|
2025-11-15 17:37:15 +01:00
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
| Stage | Task | Purpose | Idempotent |
|
|
|
|
|
|
|-------|------|---------|-----------|
|
|
|
|
|
|
| 1 | `preflight-checks.yml` | Validate environment (20+ checks) | ✅ Yes |
|
|
|
|
|
|
| 2 | `download-image.yml` | Download/cache Debian image | ✅ Yes |
|
|
|
|
|
|
| 3 | `create-vm.yml` | Create base VM | ✅ Yes |
|
|
|
|
|
|
| 4 | `configure-vm.yml` | Configure disk, network, Cloud-Init | ✅ Yes |
|
|
|
|
|
|
| 5 | `create-template.yml` | Convert to template | ✅ Yes (FIXED!) |
|
|
|
|
|
|
| 6 | `create-clones.yml` | Deploy clones from template | ✅ Yes |
|
2025-11-15 17:37:15 +01:00
|
|
|
|
|
2025-11-16 08:42:26 +01:00
|
|
|
|
## Helper Functions (tasks/helpers.yml)
|
|
|
|
|
|
|
|
|
|
|
|
All task files use centralized helper functions for consistency and maintainability:
|
|
|
|
|
|
|
|
|
|
|
|
| Helper | Purpose | Sets Variable |
|
|
|
|
|
|
|--------|---------|----------------|
|
|
|
|
|
|
| `check_vm_exists` | Check if VM config file exists | `vm_exists` |
|
|
|
|
|
|
| `check_template` | Check if VM is a template | `is_template` |
|
|
|
|
|
|
| `check_vm_status` | Get current VM status (running/stopped) | `vm_status` |
|
2025-11-18 20:24:43 +01:00
|
|
|
|
| `check_disk_attached` | Check if disk is attached via `qm config` | `disk_attached` |
|
2025-11-16 08:42:26 +01:00
|
|
|
|
| `check_storage` | Check available storage space | `storage_available` |
|
|
|
|
|
|
| `validate_vm_id` | Validate VM ID format (100-999999) | (assertions only) |
|
|
|
|
|
|
| `get_vm_info` | Read and parse VM config file | `vm_info` |
|
|
|
|
|
|
| `list_vms` | Get list of all VMs | `vm_list` |
|
|
|
|
|
|
| `cleanup_snippets` | Remove old Cloud-Init snippets | (side effect) |
|
|
|
|
|
|
|
|
|
|
|
|
### Example: Using Helpers in Tasks
|
|
|
|
|
|
```yaml
|
|
|
|
|
|
- name: Check if VM already exists
|
|
|
|
|
|
ansible.builtin.include_tasks: helpers.yml
|
|
|
|
|
|
vars:
|
|
|
|
|
|
helper_task: check_vm_exists
|
|
|
|
|
|
target_vm_id: "{{ vm_id }}"
|
|
|
|
|
|
|
|
|
|
|
|
- name: Display status
|
|
|
|
|
|
debug:
|
|
|
|
|
|
msg: "VM status: {{ 'EXISTS' if vm_exists else 'WILL BE CREATED' }}"
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2025-11-15 17:37:15 +01:00
|
|
|
|
## Key Improvements
|
|
|
|
|
|
|
|
|
|
|
|
### ✅ Error Handling
|
2025-11-15 17:39:23 +01:00
|
|
|
|
- Automatic retry with configurable delays (3x, 5-sec)
|
2025-11-15 17:37:15 +01:00
|
|
|
|
- Context-aware error messages
|
2025-11-15 17:39:23 +01:00
|
|
|
|
- Per-clone error isolation (doesn't cascade)
|
2025-11-15 17:37:15 +01:00
|
|
|
|
|
|
|
|
|
|
### ✅ Idempotency
|
|
|
|
|
|
- Safe to re-run multiple times
|
2025-11-15 17:39:23 +01:00
|
|
|
|
- Skips already-completed operations
|
|
|
|
|
|
- Image cached and reused
|
|
|
|
|
|
- **Template conversion idempotent** (was broken in v1!)
|
2025-11-16 08:42:26 +01:00
|
|
|
|
- **Per-clone checking** - skips existing clones
|
|
|
|
|
|
- **Snippet cleanup** - old files removed before re-configuration
|
|
|
|
|
|
|
|
|
|
|
|
**Idempotency per stage**:
|
|
|
|
|
|
- ✅ `create-vm.yml` - Checks if VM exists before creating
|
|
|
|
|
|
- ✅ `configure-vm.yml` - Re-applies Cloud-Init (safe to re-run)
|
|
|
|
|
|
- ✅ `create-template.yml` - Skips if already a template
|
|
|
|
|
|
- ✅ `create-clones.yml` - Skips clones that already exist (per-clone checks)
|
|
|
|
|
|
- ✅ `download-image.yml` - Skips download if file exists locally
|
2025-11-15 17:37:15 +01:00
|
|
|
|
|
|
|
|
|
|
### ✅ Pre-flight Validation
|
2025-11-15 17:39:23 +01:00
|
|
|
|
- Proxmox connectivity & permissions
|
2025-11-15 17:37:15 +01:00
|
|
|
|
- Storage pool availability
|
|
|
|
|
|
- SSH key readiness
|
|
|
|
|
|
- IP address format validation
|
|
|
|
|
|
- VM ID uniqueness checks
|
|
|
|
|
|
|
|
|
|
|
|
### ✅ Advanced Features
|
|
|
|
|
|
- UEFI/TPM 2.0 support
|
|
|
|
|
|
- GPU passthrough (PCI or VirtIO)
|
2025-11-15 17:39:23 +01:00
|
|
|
|
- Automatic disk resize
|
|
|
|
|
|
- Cloud-Init with user/password/SSH
|
2025-11-15 17:37:15 +01:00
|
|
|
|
- DHCP or static networking
|
|
|
|
|
|
- Multi-clone deployment
|
|
|
|
|
|
|
|
|
|
|
|
## Testing & Validation
|
|
|
|
|
|
|
|
|
|
|
|
### Preflight Checks
|
|
|
|
|
|
```bash
|
|
|
|
|
|
ansible-playbook tasks/main.yml --tags preflight -vvv
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
### Dry Run (Preview)
|
2025-11-15 17:37:15 +01:00
|
|
|
|
```bash
|
|
|
|
|
|
ansible-playbook tasks/main.yml --check -vv
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
### Test Idempotency
|
2025-11-15 17:37:15 +01:00
|
|
|
|
```bash
|
2025-11-15 17:39:23 +01:00
|
|
|
|
# First run
|
2025-11-15 17:37:15 +01:00
|
|
|
|
ansible-playbook tasks/main.yml -vv
|
|
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
# Second run (should be much faster)
|
2025-11-15 17:37:15 +01:00
|
|
|
|
ansible-playbook tasks/main.yml -vv
|
2025-11-15 14:34:58 +01:00
|
|
|
|
```
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
## Cloud-Init Templates
|
|
|
|
|
|
|
|
|
|
|
|
### `cloudinit_userdata.yaml.j2`
|
|
|
|
|
|
Configures:
|
|
|
|
|
|
- User creation with sudo access
|
|
|
|
|
|
- SSH key injection
|
|
|
|
|
|
- Password authentication
|
|
|
|
|
|
- Timezone setting
|
|
|
|
|
|
- Package updates
|
|
|
|
|
|
|
|
|
|
|
|
### `cloudinit_vendor.yaml.j2`
|
|
|
|
|
|
Configures:
|
|
|
|
|
|
- Package installation
|
|
|
|
|
|
- DNS settings (optional)
|
2025-11-15 17:37:15 +01:00
|
|
|
|
|
|
|
|
|
|
## Security Notes
|
|
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
⚠️ **Passwords**: Use Ansible Vault in production:
|
|
|
|
|
|
```bash
|
|
|
|
|
|
ansible-vault create group_vars/proxmox/vault.yml
|
|
|
|
|
|
```
|
|
|
|
|
|
Then reference: `ci_password: "{{ vault_ci_password }}"`
|
2025-11-15 17:37:15 +01:00
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
✅ **SSH Keys**: Automatically validated before use
|
|
|
|
|
|
✅ **Permissions**: Checks if user can run `qm` commands
|
|
|
|
|
|
✅ **No Hardcoded Secrets**: All in variables
|
2025-11-15 17:37:15 +01:00
|
|
|
|
|
|
|
|
|
|
## Best Practices
|
|
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
1. Always run with `--check` first
|
|
|
|
|
|
2. Validate environment with `--tags preflight`
|
|
|
|
|
|
3. Skip image re-download with `--skip-tags image`
|
|
|
|
|
|
4. Monitor Cloud-Init: `cloud-init status` inside VM
|
|
|
|
|
|
5. Test in dev environment first
|
|
|
|
|
|
6. Use linked clones (`full: 0`) for faster deployments
|
|
|
|
|
|
7. Enable Proxmox snippets storage
|
|
|
|
|
|
|
|
|
|
|
|
## Performance
|
|
|
|
|
|
|
|
|
|
|
|
- **First run**: ~5-10 minutes (downloads image, creates VM)
|
|
|
|
|
|
- **Re-runs**: ~30 seconds (operations skipped)
|
|
|
|
|
|
- **Linked clones**: Much faster than full clones
|
2025-11-15 17:37:15 +01:00
|
|
|
|
|
|
|
|
|
|
## Troubleshooting
|
|
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
### Preflight validation fails
|
2025-11-15 17:37:15 +01:00
|
|
|
|
```bash
|
|
|
|
|
|
ansible-playbook tasks/main.yml --tags preflight -vvv
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### Cloud-Init not applying
|
|
|
|
|
|
```bash
|
2025-11-15 17:39:23 +01:00
|
|
|
|
# Inside VM:
|
2025-11-15 17:37:15 +01:00
|
|
|
|
cloud-init status
|
|
|
|
|
|
cloud-init logs
|
|
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
# Check snippets:
|
2025-11-15 17:37:15 +01:00
|
|
|
|
ls -la /var/lib/vz/snippets/
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### SSH key issues
|
|
|
|
|
|
```bash
|
2025-11-15 17:39:23 +01:00
|
|
|
|
# Verify SSH key
|
2025-11-15 17:37:15 +01:00
|
|
|
|
ls -la ~/.ssh/id_rsa.pub
|
|
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
# Run with verbose
|
2025-11-15 17:37:15 +01:00
|
|
|
|
ansible-playbook tasks/main.yml -vvv
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
## Common Proxmox Commands
|
2025-11-15 17:37:15 +01:00
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
# List all VMs
|
|
|
|
|
|
qm list
|
|
|
|
|
|
|
|
|
|
|
|
# Check VM status
|
|
|
|
|
|
qm status 150
|
|
|
|
|
|
|
|
|
|
|
|
# View VM config
|
|
|
|
|
|
qm config 150
|
|
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
# Connect to console
|
|
|
|
|
|
qm terminal 150
|
|
|
|
|
|
|
2025-11-15 17:37:15 +01:00
|
|
|
|
# SSH into VM
|
|
|
|
|
|
ssh debian@<vm-ip>
|
|
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
# Check Cloud-Init
|
2025-11-15 17:37:15 +01:00
|
|
|
|
cloud-init status --all
|
|
|
|
|
|
```
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 17:37:15 +01:00
|
|
|
|
## Compatibility
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 17:37:15 +01:00
|
|
|
|
- **Proxmox**: 7.x, 8.x (uses `qm` CLI)
|
|
|
|
|
|
- **Debian**: Bookworm GenericCloud (configurable)
|
2025-11-15 17:39:23 +01:00
|
|
|
|
- **Ansible**: 2.9+ (standard modules)
|
|
|
|
|
|
- **Backward Compatible**: 100% ✅
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
## Support
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
Refer to:
|
|
|
|
|
|
- `defaults/main.yml` - Complete variable documentation
|
|
|
|
|
|
- Task files - Inline comments explaining implementation
|
|
|
|
|
|
- Run with `-vvv` flag for debug output
|
|
|
|
|
|
- Check `/var/lib/vz/snippets/` for Cloud-Init files
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 17:37:15 +01:00
|
|
|
|
## License
|
2025-11-15 12:58:55 +01:00
|
|
|
|
|
2025-11-15 17:39:23 +01:00
|
|
|
|
Open source - use as-is for Proxmox automation.
|