ProxMox and Terraform "VM '<id>' not found"

edymol

New Member
Nov 20, 2024
2
0
1
Hello.

I am new to ProxMox and perhaps this has been already asked, although I have not seen a similar question yet.

I am trying to use Terraform to provision my infrastructure in PoxMox but I keep on getting this error.
Code:
[CODE=bash][CODE]proxmox_vm_qemu.ubuntu_vm: Creating...
╷
│ Error: vm '8000' not found
│
│   with proxmox_vm_qemu.ubuntu_vm,
│   on main.tf line 16, in resource "proxmox_vm_qemu" "ubuntu_vm":
│   16: resource "proxmox_vm_qemu" "ubuntu_vm" {
[/CODE][/CODE]

I have created different users and roles to try to make it work but it has not worked
Screenshot 2024-11-20 at 11.41.55 AM.png

Here is the main.tf that I am using for this test

root@proxmox:~/devops/terraform# cat main.tf
terraform {
required_providers {
proxmox = {
source = "Telmate/proxmox"
version = ">= 2.9.11"
}
}
}

provider "proxmox" {
pm_api_url = var.pm_api_url
pm_user = var.pm_user
pm_password = var.pm_password
pm_debug = var.pm_debug

resource "proxmox_vm_qemu" "ubuntu_vm" {
name = "ubuntu_vm" # Name of the new VM
target_node = "proxmox" # Node where the VM will be created
clone = 8000 # Template ID for cloning the VM

# VM Resources
cpu = 2
memory = 2048
sockets = 1

# Disk Configuration
disk {
storage = "vm-pool" # Ensure this matches the storage pool for the template
size = "32G"
type = "scsi"
iothread = 1
}

# Network Configuration
network {
model = "virtio"
bridge = "vmbr0"
}

# Cloud-init Configuration
os_type = "cloud-init"
ssh_user = "devops-user"
sshkeys = file("~/.ssh/id_rsa.pub")
ipconfig0 = "ip=192.168.100.50/24,gw=192.168.100.1"
}

Here are the different templates I have created but all give back the same error.
Screenshot 2024-11-20 at 11.43.51 AM.png
I am using this versions

Bash:
root@proxmox:~/devops/terraform# pveversion
pve-manager/8.2.2/9355359cd7afbae4 (running kernel: 6.8.4-2-pve)


I also have used API token that works when used in CLI

Bash:
curl -k -X GET "https://192.168.100.27:8006/api2/json/version" -H "Authorization: PVEAPIToken=terraform@pve!terraform:285ecb71-6c"

Has anyone had the same issue recently and how was this solved?

Thank you for your help. Screenshot 2024-11-20 at 11.41.55 AM.pngScreenshot 2024-11-20 at 11.43.51 AM.png
 
Last edited:
Hi @edymol , welcome to the forum.

The terraform code is not maintained by PVE personnel, you would have to reach out to the creator of TF code for a definitive answer.
In the meantime, you can dig into the code yourself to see what API call is being generated, that may tell you what is wrong.
If there is a way to add some "print" statements, that could help as well.

Try to do the same thing via direct "curl", using your authentication token.

Good luck



Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
Hi @edymol , welcome to the forum.

The terraform code is not maintained by PVE personnel, you would have to reach out to the creator of TF code for a definitive answer.
In the meantime, you can dig into the code yourself to see what API call is being generated, that may tell you what is wrong.
If there is a way to add some "print" statements, that could help as well.

Try to do the same thing via direct "curl", using your authentication token.

Good luck



Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
Hello bbgeek13,

Thanks for your response.

I managed to fix the issue of the "not found" but now I have other issues at hand.

I fixed the issue using a different provider version and syntax.

Now I face the issue that the template VMs are not finding the bootable disk and this is the error.

proxmox_vm_qemu.ubuntu_vm[0]: Still creating... [4m20s elapsed]╷│ Error: error updating VM: 500 invalid bootorder: device 'scsi0' does not exist', error status: {"data":null} (params: map[agent:0 bios:seabios boot:eek:rder=scsi0 cores:2 cpu:host delete:ide2,scsi0 hotplug:network,disk,usb ipconfig0:ip=192.168.0.50/24 kvm:true memory:2048 name:debian-vm-1 net0:virtio=B2:6E:90:D1:32:43,bridge=vmbr0 numa:false onboot:true protection:false scsihw:virtio-scsi-pci sockets:1 tablet:true vmid:105])││ with proxmox_vm_qemu.ubuntu_vm[0],│ on main.tf line 19, in resource "proxmox_vm_qemu" "ubuntu_vm":│ 19: resource "proxmox_vm_qemu" "ubuntu_vm" {│╵

I will continue troubleshooting this and hopefully have a solid fix so I can run IoC without issues.

Thanks again
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!