bpg / terraform-provider-proxmox

Terraform / OpenTofu Provider for Proxmox VE
https://registry.terraform.io/providers/bpg/proxmox
Mozilla Public License 2.0
892 stars 140 forks source link

Confusing error message when cloning a VM with cloud-init to a non-default datastore #1462

Open fuse opened 4 months ago

fuse commented 4 months ago

Describe the bug

I’m not able to configure cloud-init while cloning VM. If I just clone the VM using terraform and configure cloud-init manually it works like a charm.

To Reproduce

I want to create a VM on a node, using a template on a different one. Without the initialization bloc it’s ok. With the block the VM is correctly created but terraform fails with :

│ Error: error updating VM: the requested resource does not exist
│ 
│   with proxmox_virtual_environment_vm.test_vm,
│   on main.tf line 1, in resource "proxmox_virtual_environment_vm" "test_vm":
│    1: resource "proxmox_virtual_environment_vm" "test_vm" {
resource "proxmox_virtual_environment_vm" "test_vm" {
  name      = "test-martin"
  node_name = "node19"

  clone {
    vm_id        = "179"
    datastore_id = "storage01"
    full         = true
    node_name    = "node09"
  }

  cpu {
    cores   = 1
    sockets = 1
  }

  memory {
    dedicated = 512
  }

  agent {
    enabled = true
  }

  network_device {
    bridge  = "vmbr0"
    vlan_id = 3305
  }

  initialization {
    ip_config {
      ipv4 {
        address = "172.16.2.57/32"
        gateway = "172.16.2.10"
      }
    }

    dns {
      servers = ["172.16.0.15", "172.16.0.16"]
      domain = "internal.xxx.fr"
    }

    user_account {
      username = "martin"
      password = "xxx"
      keys     = [
        "xxx"
      ]
    }
  }

  disk {
    datastore_id = "storage02"
    file_format  = "raw"
    interface    = "scsi0"
    size         = 5
  }
}

Any idea ?

a-mcf commented 3 months ago

I experienced this issue when I didn't specify a datastore_id under the initialization block. I don't have local-lvm, which seems to be the default. Specifying the datastore_id fixed it for me. The error message in this case is kind of hard to decipher.

fuse commented 3 months ago

Thanks a lot, that did the trick !

bpg commented 3 months ago

I'll keep the issue open. The error definitely needs to be handled better, and the message should provide actionable information.

V-Legendre commented 1 month ago

+1 on this, I am experiencing the same issue.

ratiborusx commented 1 month ago

I concur, having some feedback when you're being retard would be nice. Also happens when you're directly linking to non-existent cloud-init config (forgot that i renamed it).