Telmate / terraform-provider-proxmox

Terraform provider plugin for proxmox
MIT License
2.2k stars 534 forks source link

400 Parameter verification failed with new Terraform registry provider #248

Closed goffinf closed 4 years ago

goffinf commented 4 years ago

Terraform Version Info:

terraform -version

Your version of Terraform is out of date! The latest version
is 0.13.5. You can update by downloading from https://www.terraform.io/downloads.html
Terraform v0.13.0
+ provider registry.terraform.io/hashicorp/external v1.2.0
+ provider registry.terraform.io/hashicorp/local v1.4.0
+ provider registry.terraform.io/hashicorp/null v2.1.2
+ provider registry.terraform.io/hashicorp/template v2.1.2
+ provider registry.terraform.io/telmate/proxmox v2.6.3

Proxmox Server version: 6.2-15

Issue Description

Installed the Proxmox provider from the Terraform registry (v2.6.3 - see above).

When running terraform plan I see the error:

Error: 400 Parameter verification failed.

I have been using a locally compiled version following the instructions from the docs and this continues to work successfully for other Terraform that I have not yet updated. I want to use the published provider from the Hashicorp Terraform registry.

Terraform debug doesn't shed any further light (maybe its not getting far enough):

...
2020/11/10 16:18:11 [TRACE] buildProviderConfig for module.proxmox_vm_k8s_master.provider["registry.terraform.io/telmate/proxmox"]: using explicit config only
2020/11/10 16:18:11 [TRACE] GRPCProvider: GetSchema
2020-11-10T16:18:11.710Z [TRACE] plugin.stdio: waiting for stdio data
2020/11/10 16:18:11 [TRACE] GRPCProvider: Configure
2020/11/10 16:18:11 [ERROR] eval: *terraform.EvalConfigProvider, err: 400 Parameter verification failed.
2020/11/10 16:18:11 [ERROR] eval: *terraform.EvalSequence, err: 400 Parameter verification failed.
2020/11/10 16:18:11 [ERROR] eval: *terraform.EvalOpFilter, err: 400 Parameter verification failed.
2020/11/10 16:18:11 [ERROR] eval: *terraform.EvalSequence, err: 400 Parameter verification failed.
2020/11/10 16:18:11 [TRACE] [walkPlan] Exiting eval tree: module.proxmox_vm_k8s_master.provider["registry.terraform.io/telmate/proxmox"]
2020/11/10 16:18:11 [TRACE] vertex "module.proxmox_vm_k8s_master.provider[\"registry.terraform.io/telmate/proxmox\"]": visit complete
2020/11/10 16:18:11 [TRACE] dag/walk: upstream of "module.proxmox_vm_k8s_master.proxmox_vm_qemu.proxmox_vm (expand)" errored, so skipping
2020/11/10 16:18:11 [TRACE] dag/walk: upstream of "module.proxmox_vm_k8s_master (close)" errored, so skipping
2020/11/10 16:18:11 [TRACE] dag/walk: upstream of "meta.count-boundary (EachMode fixup)" errored, so skipping
2020/11/10 16:18:11 [TRACE] dag/walk: upstream of "module.proxmox_vm_k8s_master.provider[\"registry.terraform.io/telmate/proxmox\"] (close)" errored, so skipping
2020/11/10 16:18:11 [TRACE] dag/walk: upstream of "root" errored, so skipping
2020/11/10 16:18:11 [INFO] backend/local: plan operation completed

I did configure logging output from the provider, but no file was actually produced (again, perhaps it fails before getting far enough ??

I can see that there have been some changes to proxmox_vm_qemu resource, in particular removing id and storage_type from the disk structure and id from network and I have adjusted my definition accordingly, but I can't see any others that look wrong (the docs and examples aren't updated so its hard to tell).

Could you take a look at my .tf and see if anything obvious jumps out, or suggest any other likely culprits (has connection to the Proxmox server API changed at all ?):

Kind Regards

Fraser.

terraform {
  required_providers {
    ...

    proxmox = {
      source  = "Telmate/proxmox"
      version = "~> 2.6.3"
    }
  }
}

provider "proxmox" {
  pm_api_url      = "https://${var.proxmox_server_ip}:${var.proxmox_server_port}/api2/json"
  pm_user         = var.proxmox_server_user
  pm_password     = var.proxmox_server_pwd
  pm_tls_insecure = var.proxmox_insecure_mode
  pm_log_enable = true
  pm_log_file = "terraform-plugin-proxmox.log"
  pm_log_levels = {
    _default = "debug"
    _capturelog = ""
  }
}

# Create the VM
resource "proxmox_vm_qemu" "proxmox_vm" {

  count = var.proxmox_node_count

  name        = "${var.hostname}-${count.index}"
  target_node = var.proxmox_target_node

  # basic instance config
  cores    = 1
  sockets  = 1
  cpu      = "host"
  memory   = 2048

  disk {
    size         = "16G"
    type         = "scsi"
    storage      = "local-lvm"
    iothread     = true
  }

  serial {
    id   = 0
    type = "socket"
  }

  # Clone from the pre-prepared template (e.g. ubuntu-20-04-cloudinit-template)
  agent      = 1
  clone      = var.proxmox_template
  full_clone = false
  os_type    = "cloud-init"

  # Cloud init options
  cicustom = "user=local:snippets/${var.cloud_config_template}-${count.index}.yml"
  ipconfig0 = "ip=dhcp"

  ciuser     = var.proxmox_ssh_user
  cipassword = var.proxmox_ssh_pwd

  sshkeys = <<EOF
${var.ssh_key}
EOF

  # boot disk paramters
  boot     = "c"
  bootdisk = "scsi0"
  scsihw   = "virtio-scsi-pci"

  # network config
  network {
    model  = "virtio"
    bridge = "vmbr0"
  }

  # Ignore changes to the network
  # MAC address is generated on every apply, causing
  # TF to think that this needs to be rebuilt on every apply

  lifecycle {
    ignore_changes = [
      network,
    ]
  }
}
stefanvangastel commented 4 years ago

Same here, also in 2.6.4

goffinf commented 4 years ago

Resolved. After some further and more careful debugging (adding output vars for most of the properties for the proxmox provider and proxmox_vm_qemu resource within the module that I call), I found that the pm_password value was incorrect. Once fixed the plan verification error disappeared.