Can't get terraform to work to install VM

pfworks

New Member
Dec 25, 2024
1
0
1
Right now, I'm using the API key. This means I have to use 2.9.11 version of the terraform provider, because if I use the current version, there is something about permissions and my key no longer works. However, with 2.9.11, I can't get past this error. Also, is terraform really supported? I have yet to find a blog that produces anything that works, and still can't figure out how to use my ceph storage via terraform.


ESC[31m╷ESC[0mESC[0m
ESC[31m│ESC[0m ESC[0mESC[1mESC[31mError: ESC[0mESC[0mESC[1m400 Parameter verification failed.ESC[0m
ESC[31m│ESC[0m ESC[0m
ESC[31m│ESC[0m ESC[0mESC[0m with proxmox_vm_qemu.my-vm,
ESC[31m│ESC[0m ESC[0m on vm.tf line 25, in resource "proxmox_vm_qemu" "my-vm":
ESC[31m│ESC[0m ESC[0m 25: resource "proxmox_vm_qemu" "my-vm" ESC[4m{ESC[0mESC[0m
ESC[31m│ESC[0m ESC[0m
ESC[31m╵ESC[0mESC[0m

generated from my vm.tf

terraform {
required_providers {
proxmox = {
source = "telmate/proxmox"
version = "2.9.11"
}
}
}

provider "proxmox" {
# url is the hostname (FQDN if you have one) for the proxmox host you'd like to connect to to issue the commands. my proxmox host is 'p\
rox-1u'. Add /api2/json at the end for the API
pm_api_url = "http://proxmox-1:8006/api2/json"

# api token id is in the form of: @pam!
pm_api_token_id = "****"

# this is the full secret wrapped in quotes. don't worry, I've already deleted this from my proxmox cluster by the time you read this p\
ost
pm_api_token_secret = "****"

# leave tls_insecure set to true unless you have your proxmox SSL certificate situation fully sorted out (if you do, you will know)
pm_tls_insecure = true
pm_debug = true
}

resource "proxmox_vm_qemu" "my-vm" {
name = "my-vm"
target_node = "proxmox-1"

clone = "oracle-810-cloudinit-template"
}
 
Last edited:
I got it working following this:

https://www.youtube.com/watch?v=1kFBk0ePtxo

Its a good primer. Though, it includes the secrets in main.tf - which I do not recommend. Here is my basic main.tf (I have other tf files for other specific VMs)



JSON:
terraform {
    required_providers {
        proxmox = {
            source = "telmate/proxmox"
        }
    }
}

provider "proxmox" {
    pm_api_url          = var.api_url
    pm_api_token_id     = var.api_token_id
    pm_api_token_secret = var.api_token_secret
    pm_tls_insecure     = false
}

resource "proxmox_vm_qemu" "gitlab" {

    lifecycle {
        prevent_destroy = true
    }

    name                = "gitlab"
    target_node         = "proxmox01"
    clone               = "ubuntu-cloud"
    full_clone          = true
    cores               = 4
    memory              = 4096
    vmid                = 680

    disk {
        size            = "64G"
        type            = "scsi"
        storage         = "freenas"
        discard         = "on"
    }

    network {
        model     = "virtio"
        bridge    = "vmbr1"
        firewall  = false
        link_down = false

    }

}

In my variables.tf I have:


JSON:
variable "api_token_secret" {
description = "Secret API Token"
type = string
default = "REDACTED”
}

variable "api_url" {
description = "Proxmox main URL"
type = string
default = "REDACTED”
}

variable "api_token_id" {
description = "The ID attached to the Token"
type = string
default = "REDACTED”
}

I would try it exactly like the video, then expand out to using a variables.tf like I have above.