[SOLVED] Terraform Provider can't find template?

skirven4

New Member
May 8, 2023
2
0
1
Hi! I'm still learning ProxmoxVE, and also Terraform. I've created a VM Template "KubernetesNodeTemplate" following the instructions here: https://ochoaprojects.github.io/posts/DeployingVMsWithTerraformInProxMox/. The plan keeps showing this, and I can even clone the Template, so I'm not sure what's failing here. The logs aren't showing anything definitive. Previously, I had to fix an API Token issue, but that issue went away...

How can I list the Templates available using the "qm" command??

Provider Info:

Code:
#Configure ProxMox API user/permissions and API url
provider "proxmox" {
  pm_api_url = "https://ip_address:8006/api2/json"
  pm_api_token_id = "terraform-prov@pve!terraform"
  pm_api_token_secret = "psst"
  pm_tls_insecure = true
  pm_log_enable = true
  pm_log_file   = "terraform-plugin-proxmox-vm.log"
#  pm_debug      = true
  pm_log_levels = {
    _default    = "debug"
    _capturelog = ""
  }
}

#Configure Proxmox Resources Here
resource "proxmox_vm_qemu" "Kubernetes-Node" {
  count = 1
  name = "Kubernetes-Node-${count.index + 1}"

  target_node = var.proxmox_host

  clone = var.template_name
  #Basic VM settings here
  agent = 1 # QEMU Guest Agent, 1 means installing the guest agent on this VM is set to True
  os_type = "cloud-init"
  cores = 2
  sockets = 1
  cpu = "host"
  memory = 2048
  scsihw = "virtio-scsi-pci"
  bootdisk = "scsi0"

var.template_name does equal "KubernetesNodeTemplate" and the Proxmox console shows that value, as VM 9000, with an icon that looks like the VM icon, with a piece of paper next to it.


Eror:
Code:
Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

proxmox_vm_qemu.Kubernetes-Node[0]: Creating...
╷
│ Error: Vm 'KubernetesNodeTemplate' not found
│
│   with proxmox_vm_qemu.Kubernetes-Node[0],
│   on main.tf line 25, in resource "proxmox_vm_qemu" "Kubernetes-Node":
│   25: resource "proxmox_vm_qemu" "Kubernetes-Node" {
│
╵

How can I best troubleshoot this?
Thanks!
 
Solved! So it appears to be something with the API Token or Permissions. I have to dig into that, but the work around was to hard code the root password into the file, and it found the template!
 
Any update on the permissions? I'm having the same issue. I've tried giving it all the permissions though
 

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!