Files
PSProxmoxVE/tests/infrastructure/main.tf
T
Clint Branham 9817d30a11 feat(ci): multi-node PVE provisioning and Docker-based shared storage
Provision two PVE nodes per version (a/b) for future cluster testing,
plus Docker-based iSCSI target and NFS server for shared storage tests.

Multi-node changes:
- Each PVE version gets two nodes: 9a/9b and 8a/8b (4 VMs total)
- Parameterized answer.toml FQDN for unique hostnames per node
- Per-node auto-install ISOs with unique answer files
- Node name discovered from FQDN and included in test config
- API token creation handles pre-existing tokens (delete + recreate)
- New test env vars: PVETEST_HOST_B, PVETEST_APITOKEN_B
- Removed preflight cleanup from provision (use explicit cleanup instead)

Docker storage services:
- New docker-compose.storage.yml with iSCSI (tgt) and NFS containers
- Host networking so PVE nodes can reach storage services
- Docker socket mounted into dev-infra container for host Docker access
- Docker CLI added to dev-infra Dockerfile stage
- New test env vars: PVETEST_STORAGE_VM_IP, PVETEST_ISCSI_IQN, PVETEST_NFS_EXPORT

Other fixes:
- first-boot.sh installs open-iscsi on PVE nodes
- preflight-cleanup.sh handles empty ISO filename gracefully
- TMPDIR set to work dir to avoid /tmp overflow during ISO uploads

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 13:34:15 -05:00

86 lines
1.6 KiB
Terraform

terraform {
required_version = ">= 1.5.0"
required_providers {
proxmox = {
source = "bpg/proxmox"
version = ">= 0.70.0"
}
}
}
provider "proxmox" {
endpoint = var.proxmox_endpoint
api_token = var.proxmox_api_token
insecure = var.proxmox_insecure
}
resource "proxmox_virtual_environment_file" "auto_iso" {
for_each = var.pve_instances
content_type = "iso"
datastore_id = var.iso_storage
node_name = var.target_node
source_file {
path = each.value.iso_local_path
}
}
# ── Nested PVE VMs ────────────────────────────────────────────────────
resource "proxmox_virtual_environment_vm" "nested_pve" {
for_each = var.pve_instances
name = each.value.vm_name
node_name = var.target_node
vm_id = each.value.vm_id
machine = "q35"
bios = "ovmf"
boot_order = ["scsi0", "ide2"]
cpu {
type = "host"
cores = var.cores
sockets = 1
}
memory {
dedicated = var.memory
}
efi_disk {
datastore_id = var.disk_storage
type = "4m"
}
disk {
datastore_id = var.disk_storage
interface = "scsi0"
size = var.disk_size
file_format = "raw"
}
cdrom {
file_id = proxmox_virtual_environment_file.auto_iso[each.key].id
interface = "ide2"
}
network_device {
bridge = var.network_bridge
model = "virtio"
}
operating_system {
type = "l26"
}
agent {
enabled = true
}
started = true
lifecycle {
ignore_changes = [started, cdrom]
}
}