For those using Telemate as your terraform provider there is now a fix in place related to the Proxmox 9 permission issue in the release of 3.0.2-rc04. There are some changes you will need to be aware of with this release.
1 - A CPU block is now required.
2 - In the network block, it now require a network ID. The network ID needs to be in sequence. ie: 0, 1, 2, 3 etc.
Here is a example of the terraform code with the changes I am currently using..
resource "proxmox_vm_qemu" "<TF Module Name>" {
name = "<Server Name>>"
vmid = <VM ID>
agent = 1
onboot = true
os_type = var.os_type
qemu_os = var.qemu_os
ciuser = var.ciuser
memory = <Memory Size>
tags = var.tags_11
######## New CPU Block #########
cpu {
cores = 4
sockets = 2
type = "host"
}
#Display
vga {
type = "virtio"
#Between 4 and 512, ignored if type is defined to serial
memory = 512
}
scsihw = "virtio-scsi-single"
bootdisk = "scsi0"
disks {
ide {
ide2 {
cloudinit {
}
}
}
scsi {
scsi0 {
disk {
size = 100
iothread = true
cache = "writeback"
emulatessd = true
discard = true
}
}
}
}
sshkeys = <<EOF
<SSH Key Here>
EOF
lifecycle {
ignore_changes = [network, sshkeys]
}
######## Network ID #########
network {
id = 0
model = "virtio"
bridge = "vmbr1"
}
ipconfig0 = "ip=<Server IP/CIDR>,gw=<Router Gateway IP>"
nameserver = "<DNS IP>
}
After updating the provider and running Terraform inti, you will see errors in your main.tf file. Also if you run a terraform plan, you will receive the following errors if you have already created previous VM's. Error: Unsupported argument
│
│ on main.tf line 99, in resource "proxmox_vm_qemu" "Module Name": │ 99: cpu = "host"
│
│ An argument named "cpu" is not expected here. Did you mean "vcpus"?
╵
╷
│ Error: Missing required argument
│
│ on main.tf line 143, in resource "proxmox_vm_qemu" "Module Name": │ 143: network {
│
│ The argument "id" is required, but no definition was found.
All you need to do just update the main.tf per the example above for each of the VM sections to fix this and the errors will go away. When you run terraform plan again the initial error is gone and replaced by the following error: Planning failed. Terraform encountered an error while generating this plan.
│ Error: missing expected [
│
│ with proxmox_vm_qemu.<MODULE NAME>,
│ on main.tf line 87, in resource "proxmox_vm_qemu" "<MODULE NAME>": │ 87: resource "proxmox_vm_qemu" "<MODULE NAME>" {
This is cause by the terraform.tfstate not matching the main.tf and you will receive this error for each of the VMs in the state file. Depending on many VMs in your state file, you have two options. 1 - Backup and than delete the current state file. This will not affected the VMs already created but just starting from scratch with the state file.
2 - Edit the current state file to match the main.tf (see print screens below). Here is a example of the updated CPU block within the state file:
"cpu": [
{
"affinity": "",
"cores": 2,
"flags": [],
"limit": 0,
"numa": false,
"sockets": 1,
"type": "host",
"units": 0,
"vcores": 0
}
],
"cpu_type": "",
This is an example of the network section:
"network": [
{
"bridge": "vmbr1",
"firewall": false,
"id": 0,
"link_down": false,
"macaddr": "<MAC ADDRESS>",
"model": "virtio",
"mtu": 0,
"queues": 0,
"rate": 0,
"tag": 0
}
],
After applying all the changes into the state file and run terraform plan again, you will get the following showing the files are in sync.
No changes. Your infrastructure matches the configuration.
Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
Now you will be good to start creating new VM's without any issues.
Let me know if you have any questions.