mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-07-26 07:58:14 +00:00
94d5fe9944
Terraform creates resources in parallel. Without depends_on, PVE VMs could boot and start the auto-installer before the HTTP answer server container is running, causing "could not find answer file" errors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
101 lines
2.0 KiB
Terraform
101 lines
2.0 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
|
|
|
|
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]
|
|
}
|
|
}
|