Files
PSProxmoxVE/tests/infrastructure/main.tf
T
Clint Branham d3f05187dd ci: nested PVE guests land in the ci pool with VMIDs 5081-5092
The runner token is pool-scoped (PVEVMAdmin on /pool/ci only), so VM.Allocate
succeeds only with pool_id set; VMIDs move into the 5000-5999 CI range.
2026-08-23 09:06:11 -05:00

102 lines
2.1 KiB
Terraform

terraform {
required_version = ">= 1.5.0"
required_providers {
proxmox = {
source = "bpg/proxmox"
version = ">= 0.70.0"
}
docker = {
source = "kreuzwerker/docker"
version = ">= 3.0.0"
}
}
}
provider "proxmox" {
endpoint = var.proxmox_endpoint
api_token = var.proxmox_api_token
insecure = var.proxmox_insecure
}
provider "docker" {
# Uses the Docker socket from the dev-infra container
# (mounted at /var/run/docker.sock)
}
resource "proxmox_virtual_environment_file" "auto_iso" {
for_each = var.pve_isos
content_type = "iso"
datastore_id = var.iso_storage
node_name = var.target_node
overwrite = true
source_file {
path = each.value
}
}
# ── 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
pool_id = var.pool_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.value.pve_version].id
interface = "ide2"
}
network_device {
bridge = var.network_bridge
model = "virtio"
mac_address = each.value.mac_address
}
operating_system {
type = "l26"
}
agent {
enabled = true
}
started = true
# VMs must not boot until the HTTP answer server is running,
# otherwise the PVE auto-installer can't fetch its answer file.
depends_on = [docker_container.answer_server]
lifecycle {
ignore_changes = [started, cdrom]
}
}