Replies: 2 comments 2 replies
-
Good question! With the older disk {} way it was easy with dynamic block, exemple here: https://github.com/julienym/myTerraformModules/blob/2.1.1/proxmox/main.tf#L21 But now if you import a VM, it will by default use the new disks {} which I don't see how can be used dynamically |
Beta Was this translation helpful? Give feedback.
-
Any news on this? I have the same problem. and wanted to post my own discussion, appending my question text: IntroductionHello together, I'm struggling with something and I can't find a solution in the documentation nor can ChatGPT. I've written my own module to generate virtualmachines inside a Proxmox cluster. Code basisresource "proxmox_vm_qemu" "virtualmachine" {
name = var.vm_name
desc = var.vm_description
target_node = var.target_node
vmid = var.vm_id
clone = var.clone_vm_name
agent = var.agent
pool = var.pool
os_type = var.os_name
cores = var.cores
sockets = var.sockets
memory = var.memory
balloon = var.memory
tags = var.tags
scsihw = var.scsihw
disks {
ide {
dynamic "ide3" {
for_each = var.cloudinit == true ? [1] : []
content {
cloudinit {
storage = var.storage
}
}
}
}
scsi {
scsi0 {
disk {
size = var.main_disk_size
storage = var.storage
}
}
}
}
network {
bridge = var.bridge
model = "virtio"
firewall = var.firewall
tag = var.network_tag
}
ipconfig0 = var.ipconfig0
ciuser = var.ciuser
cipassword = var.cipassword
sshkeys = var.ssh_keys
boot = "order=scsi0"
} My question is about the I have my main disk and a possible cloudinit disk set up for all VMs. They will always be the same. Some VMs will receive multiple disks for LVM encryption so I need to generate these. QuestionCan I somehow generate additional SCSI disks here with tofu code that depend on a variable? e.g. variable "additional_disks" {
description = "List of additional disks to be attached to the VM"
type = list(object({
size = string
storage = string
}))
default = []
} With this variable I'd like to have Any ideas? |
Beta Was this translation helpful? Give feedback.
-
Hello.
I use this provider to create cloud-init vm's as the following:
I define the vm's as modules within the main.tf.
E.g.:
main.tf
modules/vms/main.tf
I now try to add an optional 2nd scsi disk for kubernetes downstream nodes but don't know how to make it truely optional.
My idea was, that it only get created when I specify a
disk_size2
within the module.Kind regards
Lucas
Beta Was this translation helpful? Give feedback.
All reactions