Files

73 lines
1.2 KiB
Terraform

resource "proxmox_virtual_environment_vm" "vm" {
for_each = var.vms
name = each.key
node_name = "proxmox"
# vm_id omitted — Proxmox auto-assigns the next available ID
clone {
vm_id = 9001 # debian-12-cloud template
full = true
}
agent {
enabled = true
}
cpu {
cores = each.value.cores
type = "x86-64-v2-AES"
}
memory {
dedicated = each.value.memory
}
scsi_hardware = "virtio-scsi-single"
disk {
datastore_id = "local-lvm"
interface = "scsi0"
size = each.value.disk_size
discard = "on"
iothread = true
}
network_device {
bridge = "vmbr0"
model = "virtio"
}
operating_system {
type = "l26"
}
initialization {
datastore_id = "local-lvm"
ip_config {
ipv4 {
address = "dhcp"
}
}
user_account {
username = "debian"
keys = [var.ssh_public_key]
}
}
lifecycle {
ignore_changes = [
initialization[0].user_account[0].password,
]
}
}
output "vm_ip_addresses" {
value = {
for name, vm in proxmox_virtual_environment_vm.vm :
name => [for ip in flatten(vm.ipv4_addresses) : ip if ip != "127.0.0.1"]
}
}