bpg / terraform-provider-proxmox

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

cannot provision VMs after changing DNS setting #1582

Closed gorgonzola5000 closed 1 month ago

gorgonzola5000 commented 1 month ago

After provisioning a VM with:

dns {
  servers = ["10.2.137.1"]
}

I cannot provision any VMs. Independent of dns block presence in the plan. VM creation fails during terraform apply:

Error message:

#1: received an HTTP 400 response - Reason: Parameter verification failed. (name: invalid format - value does not look like a valid DNS name)

My config file (notice no 'dns' block inside 'initialization' block). VM creation still fails

resource "proxmox_virtual_environment_vm" "debian_12_homelab" {
  name        = "debian_12_homelab"
  description = "Managed by Terraform"
  tags        = ["terraform", "debian"]

  node_name = "pve"
  vm_id     = 222

  agent {
    # read 'Qemu guest agent' section, change to true only when ready
    enabled = true
  }
  # if agent is not enabled, the VM may not be able to shutdown properly, and may need to be forced off
  stop_on_destroy = true

  disk {
    datastore_id = "local-lvm"
    file_id      = "local:iso/debian12-homelab-qcow2.iso"
    interface    = "scsi0"
    size         = 20
  }

  initialization {
    ip_config {
      ipv4 {
        address = "10.2.137.11/24"
        gateway = "10.2.137.1"
      }
    }

  }

  network_device {
    bridge = "vmbr0"
  }
}

My setup:

I set up bpg/proxmox provider with:

What I did to resolve the issue:

terraform DEBUG log dump: https://pastebin.com/KrmN5W55 log dump from /var/log/pveproxy: https://pastebin.com/jTYqD2yB

gorgonzola5000 commented 1 month ago

#1: received an HTTP 400 response - Reason: Parameter verification failed. (name: invalid format - value does not look like a valid DNS name) - coincidentally, I changed the dns block inside the initialization block when this error message started appearing. I became so fixated on 'DNS' that I just glanced over 'name: invalid format'. I was so hopeless that I even started looking into Proxmox source code to find the function which checks if a DNS name is valid and the exact regex used for validation. Only after this I managed to spot the error - '_' instead of '-' in 'name' of the VM.