Skip to content

Conversation

@TobiPeterG
Copy link

This fixes #1413

I will test the changes now and see if it works as expected.

@TobiPeterG
Copy link
Author

Tested it, this seems to fix the issue. Now the provider won't wait for the VM to come up with cloud-init.

However, I noticed that a destroy action might not work and also cause a 500 error when the guest agent is not running in the VM yet. Maybe the error message during creation or destruction with agent = 1 should be extended to not only show the 500 error, but also show that the guest agent is enabled but might not be running yet on the VM.

@TobiPeterG TobiPeterG marked this pull request as ready for review October 2, 2025 11:36
@TobiPeterG
Copy link
Author

Hmm I installed the guest agent on the VM and tried to delete it but I got a 500 error and the VM is not destroyed. Will investigate

@TobiPeterG
Copy link
Author

Curious, on the server itself I don't see a 500 error.
It only made two calls:
::ffff:10.124.31.44 - OpenTofu@pve!OpenTofu [02/10/2025:11:44:28 +0000] "GET /api2/json/nodes/cx39/qemu/198/pending HTTP/1.1" 200 545
::ffff:10.124.31.44 - OpenTofu@pve!OpenTofu [02/10/2025:11:44:28 +0000] "GET /api2/json/nodes/cx39/qemu/198/status/current HTTP/1.1" 200 850

@TobiPeterG
Copy link
Author

TobiPeterG commented Oct 2, 2025

The 500 error also occurs with your current master version, so I don't think I caused it. Can this be confirmed?

My main.tf that I used for my provider version and your master version:

provider "proxmox" {
  pm_api_url      = "OURAPIURL"
  pm_api_token_id = "OpenTofu@pve!OpenTofu"
  pm_api_token_secret = "OURTOKEN"
  pm_tls_insecure = true
}

resource "proxmox_vm_qemu" "vm" {
  name         = "local-test"
  protection   = false
  target_nodes = ["OURNODENAME"]
  memory       = 4096
  scsihw       = "virtio-scsi-pci"
  clone        = "OURTEMPLATE"
  os_type      = "cloud-init"
  pool         = "OURPOOL"
  agent        = 1

  cpu {
    cores   = 4
    sockets = 1
    type    = "host"
  }

  network {
      id      = 0
      model   = "virtio"
      bridge  = "vmbr0"
      tag     = OURVLAN
  }

  disks {
    scsi {
      scsi0 {
        disk {
          size    = 40
          storage = "OURSTORAGE"
        }
      }
    }
    ide {
      ide2 {
        cdrom {
          iso = "OURSTORAGEPOOL:iso/OURISONAME.iso"
        }
      }
    }
  }
  lifecycle {
    ignore_changes = [
      agent_timeout,
      disks[0].ide[0].ide2[0].cdrom[0].iso,
      target_node,
      target_nodes,
      agent
    ]
  }
}

With this setup I also confirmed that VM creation works without problems with my provider and fails with yours.
VM deletion fails with both versions, but I'm very sure that's another issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VM creation fails with cloud-init VM with guest agent enabled

1 participant