Open Stormfox2 opened 3 months ago
Yeah, I observe the same behavior when I try to create a virtual machine with pci device: "3.0.1-rc2"
variable:
variable "vm_pci_devices" {
type = list(object({
id = string
rombar = number
pcie = number
}))
default = []
}
resource:
dynamic hostpci {
for_each = var.vm_pci_devices
content {
host = hostpci.value.id
rombar = hostpci.value.rombar
pcie = hostpci.value.pcie
}
}
module with variable:
vm_pci_devices = [
{ id = "0000:00:02", rombar = 1, pcie = 0 }
]
Error:
Error: Invalid address to set: []string{"hostpci", "0", "id"}
│
│ with module.altair.proxmox_vm_qemu.proxmox_vm[0],
│ on modules\proxmox-vm-qemu\main.tf line 1, in resource "proxmox_vm_qemu" "proxmox_vm":
│ 1: resource "proxmox_vm_qemu" "proxmox_vm" {
@mleone87 , Hi. Any comments?
Hey @Aksogen @Stormfox2 maybe this PR will help with your issue? https://github.com/Telmate/terraform-provider-proxmox/pull/1070
Actually did not fixed for me :O I'm using the master branch binary Proxmox Version: 8.2.3 Resource:
resource "proxmox_vm_qemu" "k0s-gpu-worker" {
name = "k0s-gpu-worker"
target_node = "cloud"
desc = "GPU worker k0s"
onboot = true
clone = "d12-normal-gpu"
agent = 0
machine = "q35"
hostpci {
host = "p40"
pcie = 0
rombar = 1
}
os_type = "cloud-init"
numa = true
cpu = "host"
scsihw = "virtio-scsi-single"
bootdisk = "scsi0"
disks {
ide {
ide3 {
cloudinit {
storage = "local-lvm"
}
}
}
scsi {
scsi0 {
disk {
storage = "local-lvm"
size = 100
}
}
}
}
network {
model = "virtio"
bridge = "vmbr0"
firewall = false
}
}
Error:
{
"data":null,
"errors":{"hostpci0":"invalid format - format error\nhostpci0.host: value does not match the regex pattern\n"}} (params: map[agent:0 balloon:0 bios:seabios cicustom: ciupgrade:0 cores:1 cpu:host delete:ide2,searchdomain,shares description:GPU worker k0s hostpci0:pcie=0,host=p40,rombar=1 hotplug:network,disk,usb ide3:local-lvm:cloudinit,format=raw kvm:true machine:q35 memory:512 name:k0s-gpu-worker ,bridge=vmbr0 numa:1 onboot:true protection:false scsi0:local-lvm:vm-103-disk-0,replicate=0 scsihw:virtio-scsi-single sockets:1 tablet:true vmid:103])
After running terraform apply
again:
proxmox_vm_qemu.k0s-gpu-worker: Refreshing state... [id=cloud/qemu/103]
╷
│ Error: unable to set hostpci: Invalid address to set: []string{"hostpci", "0", "mapping"}
│
│ with proxmox_vm_qemu.k0s-gpu-worker,
│ on main.tf line 190, in resource "proxmox_vm_qemu" "k0s-gpu-worker":
│ 190: resource "proxmox_vm_qemu" "k0s-gpu-worker" {
│
╵
but ~~~ When I use the following config: With the following commented:
# machine = "q35"
# hostpci {
# host = "p40"
# pcie = 0
# rombar = 1
# }
It stills return the error:
proxmox_vm_qemu.k0s-gpu-worker: Refreshing state... [id=cloud/qemu/103]
╷
│ Error: unable to set hostpci: Invalid address to set: []string{"hostpci", "0", "mapping"}
│
│ with proxmox_vm_qemu.k0s-gpu-worker,
│ on main.tf line 190, in resource "proxmox_vm_qemu" "k0s-gpu-worker":
│ 190: resource "proxmox_vm_qemu" "k0s-gpu-worker" {
│
╵
But the VM starts, and:
I believe there's something wrong with the regex and or the validation in the CI routine. Or something Idk. I Hope it helped.
Hey @m-da-costa, looks like you're encountering two different problems that are unrelated to OP's id
error.
hostpci0.host: value does not match the regex pattern
I guess you'll have to check what's up with the host that (as the error points out) does not meet the regex rule. Here I have no clue.
Invalid address to set: []string{"hostpci", "0", "mapping"}
I believe that mapping
is simply not supported at this time by this plugin. I have it on my roadmap somewhere down the line, if nobody else adds this feature in the meantime, I'll ping you when the PR is open, with support for mapping
.
@lucian-tx honestly, pcie devices were never fully implemented in the proxmox-go-api library that the Terraform provider uses to connect to PVE. I have this on the roadmap for that library, but until it's reimplemented there, we can only really apply bandaid fixes in the Terraform provider. The Terraform provider should only require logic to map between its data structure and the library. The library is doing all the heavy lifting in when it comes to dealing with all the little quirks of PVE.
after adding hostpci disk I receive the same error. are there some workaround ?
│ Error: Invalid address to set: []string{"hostpci", "0", "id"} │ │ with proxmox_vm_qemu.rke-node-pool[3], │ on worker_node.tf line 1, in resource "proxmox_vm_qemu" "rke-node-pool": │ 1: resource "proxmox_vm_qemu" "rke-node-pool" { │
Hey, I'm trying to add two hostpci devices to one of my vms. Everything worked until I try to run another terraform plan.
From the logs: