packer-plugin-vsphere icon indicating copy to clipboard operation
packer-plugin-vsphere copied to clipboard

Crash when connecting with `insecure_connection=false`

Open lindhe opened this issue 1 year ago • 1 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Overview of the Issue

I'm working towards a vcenter server with a TLS certificate form a private CA. If I'm trying to build a VM using Packer, with insecure_connection=false, then it crashes. If I add the cert to my host, or if I use insecure_connection=true, it works as intended.

Posting this since I was greeted with this:

!!!!!!!!!!!!!!!!!!!!!!!!!!! PACKER CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Packer crashed! This is always indicative of a bug within Packer.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Packer[1] so that we can fix this.

[1]: https://github.com/hashicorp/packer/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! PACKER CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Reproduction Steps

Run packer build . with the simplified packer template shown below.

Packer version

$ packer version
Packer v1.10.3

Simplified Packer Template

packer {
  required_version = ">= 1.7.0"
  required_plugins {
    vsphere = {
      version = "~> 1.2.0"
      source  = "github.com/hashicorp/vsphere"
    }
  }
}

source "vsphere-iso" "foo" {

  insecure_connection = false  # 👈 If this is `false`, things crash!

  cluster              = var.vcenter_cluster
  datacenter           = var.vcenter_datacenter
  datastore            = var.vcenter_datastore
  password             = var.vcenter_password
  ssh_username         = "bar"
  storage {
    disk_size             = 32 * 1024
    disk_thin_provisioned = true
  }
  username       = var.vcenter_username
  vcenter_server = var.vcenter_server
  vm_name        = "buz"

}

build {
  sources = ["source.vsphere-iso.foo"]
}

Operating system and Environment details

Ubuntu 22.04.4 LTS as a WSL2 environment on Windows 11.

Log Fragments and crash.log files

crash.log

lindhe avatar May 15 '24 07:05 lindhe

Hi @lindhe,

Thanks for the bug report!

While this Unexpected EOF which caused Packer to crash is coming from the SDK (likely even gob), the underlying problem is coming from a nil driver that gets coerced in the Cleanup code of the connect step for some reason.

Fixing the serialisation/stream EOF error will take some time, but this vsphere bug can be independently addressed I'd think.

lbajolet-hashicorp avatar May 17 '24 14:05 lbajolet-hashicorp

Interestingly, I get the expected error:

==> vsphere-iso.linux-photon: Post "https://m01-vc01.rainpole.io/sdk":
    tls: failed to verify certificate: x509: certificate signed by unknown authority

tenthirtyam avatar May 30 '24 22:05 tenthirtyam

Oh really? That is surprising. Same packer version? And did you try with my example or a different one?

Is your vcenter_server variable set to m01-vc01.rainpole.io or https://m01-vc01.rainpole.io or something else?

lindhe avatar May 31 '24 07:05 lindhe