panic: runtime error: invalid memory address or nil pointer dereference
Closed this issue · 2 comments
When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.
Overview of the Issue
Building windows 2019 template fails with error "panic: runtime error: invalid memory address or nil pointer dereference"
Reproduction Steps
PACKER_LOG=1 packer build -debug -var 'vsphere_endpoint=10.10.10.10' -var 'vsphere_username=myuser' -var 'vsphere_password=mypassword' -var 'vsphere_insecure_connection=true' .
Plugin and Packer version
Packer v1.8.6
Simplified Packer Buildfile
packer {
required_version = ">= 1.8.4"
required_plugins {
vsphere = {
version = ">= v1.1.0"
source = "github.com/hashicorp/vsphere"
}
}
}
source "vsphere-clone" "ubuntu-2004-test1" {
vcenter_server = var.vsphere_endpoint
username = var.vsphere_username
password = var.vsphere_password
insecure_connection = var.vsphere_insecure_connection
datacenter = "hrc-1c-dev-dc"
cluster = "hrc-1c-dev-dedicated-tenant-cluster"
folder = "tenanat43-windows-01 (98cbbd1d-4e18-40fe-8309-fb8ebe20a62b)"
datastore = "DS_HRC_GPU_X50_L251"
vm_name = "packer-test1"
communicator = "winrm"
customize {
windows_options {
computer_name = "balaji-windows-template01"
}
network_interface {
ipv4_address = "192.168.144.20"
ipv4_netmask = "24"
}
ipv4_gateway = "192.168.144.1"
dns_server_list = ["192.168.144.44"]
}
template = "windows-template-test01"
network = "tenant43-ntw-72a59d1a-398e-4018-8dbd-5afa8ca60d40"
tools_sync_time = "true"
winrm_password = "vPX4jvkn8Xvvz8"
winrm_username = "Administrator"
}
build {
name = "Windows Server 2019"
sources = [
"source.vsphere-clone.ubuntu-2004-test1"
]
provisioner "powershell" {
inline = [
"Write-Output \"Building Windows templates using packer\" > c:/Users/Administrator/packer-testing01.txt"
]
}
}
root@linux-vm-automation:~/packer/windows# cat variables.pkr.hcl
variable "vsphere_endpoint" {
type = string
description = "The fully qualified domain name or IP address of the vCenter Server instance. (e.g. 'sfo-w01-vc01.sfo.rainpole.io')"
}
variable "vsphere_username" {
type = string
description = "The username to login to the vCenter Server instance. (e.g. 'svc-packer-vsphere@rainpole.io')"
sensitive = true
}
variable "vsphere_password" {
type = string
description = "The password for the login to the vCenter Server instance."
sensitive = true
}
variable "vsphere_insecure_connection" {
type = bool
description = "Do not validate vCenter Server TLS certificate."
}
root@linux-vm-automation:~/packer/windows#
Operating system and Environment details
Virtualization: vmware
Operating System: Ubuntu 20.04.2 LTS
Kernel: Linux 5.4.0-135-generic
Architecture: x86-64
Log Fragments and crash.log files
root@linux-vm-automation:~/packer/windows# PACKER_LOG=1 packer build -debug -var 'vsphere_endpoint=172.16.6.115' -var 'vsphere_username=bvedagiri@onecloud.local' -var 'vsphere_password=Soniabindu@11' -var 'vsphere_insecure_connection=true' .
2023/04/05 17:57:01 [INFO] Packer version: 1.8.6 [go1.18.9 linux amd64]
2023/04/05 17:57:01 [TRACE] discovering plugins in /usr/bin
2023/04/05 17:57:01 [TRACE] discovering plugins in /root/.config/packer/plugins
2023/04/05 17:57:01 [DEBUG] Discovered plugin: vsphere = /root/.config/packer/plugins/github.com/hashicorp/vsphere/packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64
2023/04/05 17:57:01 [INFO] found external [clone iso supervisor] builders from vsphere plugin
2023/04/05 17:57:01 [INFO] found external [-packer-default-plugin-name- template] post-processors from vsphere plugin
2023/04/05 17:57:01 [TRACE] discovering plugins in .
2023/04/05 17:57:01 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2023/04/05 17:57:01 [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2023/04/05 17:57:01 [WARN] Config file doesn't exist: /root/.packerconfig
2023/04/05 17:57:01 [INFO] Setting cache directory: /root/.cache/packer
2023/04/05 17:57:01 [TRACE] listing potential installations for "github.com/hashicorp/vsphere" that match ">= v1.1.0". plugingetter.ListInstallationsOptions{FromFolders:[]string{"/usr/bin/packer", ".", "/root/.config/packer/plugins"}, BinaryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"linux", ARCH:"amd64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*sha256.digest)(0xc00016d200)}}}}
2023/04/05 17:57:01 [TRACE] Found the following "github.com/hashicorp/vsphere" installations: [{/root/.config/packer/plugins/github.com/hashicorp/vsphere/packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 v1.1.1}]
2023/04/05 17:57:01 [INFO] found external [clone iso supervisor] builders from vsphere plugin
2023/04/05 17:57:01 [INFO] found external [-packer-default-plugin-name- template] post-processors from vsphere plugin
2023/04/05 17:57:01 [TRACE] validateValue: not active for vsphere_endpoint, so skipping
2023/04/05 17:57:01 [TRACE] validateValue: not active for vsphere_username, so skipping
2023/04/05 17:57:01 [TRACE] validateValue: not active for vsphere_password, so skipping
2023/04/05 17:57:01 [TRACE] validateValue: not active for vsphere_insecure_connection, so skipping
2023/04/05 17:57:01 [TRACE] Starting external plugin /root/.config/packer/plugins/github.com/hashicorp/vsphere/packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 start builder clone
2023/04/05 17:57:01 Starting plugin: /root/.config/packer/plugins/github.com/hashicorp/vsphere/packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 []string{"/root/.config/packer/plugins/github.com/hashicorp/vsphere/packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64", "start", "builder", "clone"}
2023/04/05 17:57:01 Waiting for RPC address for: /root/.config/packer/plugins/github.com/hashicorp/vsphere/packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64
2023/04/05 17:57:01 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: 2023/04/05 17:57:01 Plugin address: unix /tmp/packer-plugin765478347
2023/04/05 17:57:01 Received unix RPC address for /root/.config/packer/plugins/github.com/hashicorp/vsphere/packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64: addr is /tmp/packer-plugin765478347
2023/04/05 17:57:01 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: 2023/04/05 17:57:01 Waiting for connection...
2023/04/05 17:57:01 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: 2023/04/05 17:57:01 Serving a plugin connection...
2023/04/05 17:57:01 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: 2023/04/05 17:57:01 [TRACE] starting builder clone
2023/04/05 17:57:01 [TRACE] Starting internal plugin packer-provisioner-powershell
2023/04/05 17:57:01 Starting plugin: /usr/bin/packer []string{"/usr/bin/packer", "plugin", "packer-provisioner-powershell"}
2023/04/05 17:57:01 Waiting for RPC address for: /usr/bin/packer
2023/04/05 17:57:02 packer-provisioner-powershell plugin: [INFO] Packer version: 1.8.6 [go1.18.9 linux amd64]
2023/04/05 17:57:02 packer-provisioner-powershell plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2023/04/05 17:57:02 packer-provisioner-powershell plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig
2023/04/05 17:57:02 packer-provisioner-powershell plugin: [WARN] Config file doesn't exist: /root/.packerconfig
2023/04/05 17:57:02 packer-provisioner-powershell plugin: [INFO] Setting cache directory: /root/.cache/packer
2023/04/05 17:57:02 packer-provisioner-powershell plugin: args: []string{"packer-provisioner-powershell"}
2023/04/05 17:57:02 Received unix RPC address for /usr/bin/packer: addr is /tmp/packer-plugin2271292727
2023/04/05 17:57:02 packer-provisioner-powershell plugin: Plugin address: unix /tmp/packer-plugin2271292727
2023/04/05 17:57:02 packer-provisioner-powershell plugin: Waiting for connection...
2023/04/05 17:57:02 packer-provisioner-powershell plugin: Serving a plugin connection...
Debug mode enabled. Builds will not be parallelized.
2023/04/05 17:57:02 Build debug mode: true
Windows Server 2019.vsphere-clone.ubuntu-2004-test1: output will be in this color.
2023/04/05 17:57:02 Force build: false
2023/04/05 17:57:02 On error:
2023/04/05 17:57:02 Debug enabled, so waiting for build to finish: Windows Server 2019.vsphere-clone.ubuntu-2004-test1
2023/04/05 17:57:02 Starting build run: Windows Server 2019.vsphere-clone.ubuntu-2004-test1
2023/04/05 17:57:02 Running builder:
2023/04/05 17:57:02 [INFO] (telemetry) Starting builder vsphere-clone.ubuntu-2004-test1
==> Windows Server 2019.vsphere-clone.ubuntu-2004-test1: Pausing after run of step 'StepConnect'. Press enter to continue.
2023/04/05 17:57:04 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: 2023/04/05 17:57:04 No CD files specified. CD disk will not be made.
==> Windows Server 2019.vsphere-clone.ubuntu-2004-test1: Pausing after run of step 'StepCreateCD'. Press enter to continue.
==> Windows Server 2019.vsphere-clone.ubuntu-2004-test1: Pausing after run of step 'StepRemoteUpload'. Press enter to continue.
==> Windows Server 2019.vsphere-clone.ubuntu-2004-test1: Cloning VM...
==> Windows Server 2019.vsphere-clone.ubuntu-2004-test1: Pausing after run of step 'StepCloneVM'. Press enter to continue.
==> Windows Server 2019.vsphere-clone.ubuntu-2004-test1: Pausing after run of step 'StepConfigureHardware'. Press enter to continue.
==> Windows Server 2019.vsphere-clone.ubuntu-2004-test1: Mounting ISO images...
==> Windows Server 2019.vsphere-clone.ubuntu-2004-test1: Pausing after run of step 'StepAddCDRom'. Press enter to continue.
==> Windows Server 2019.vsphere-clone.ubuntu-2004-test1: Adding configuration parameters...
==> Windows Server 2019.vsphere-clone.ubuntu-2004-test1: Pausing after run of step 'StepConfigParams'. Press enter to continue.
==> Windows Server 2019.vsphere-clone.ubuntu-2004-test1: Pausing before cleanup of step 'StepConfigParams'. Press enter to continue.
==> Windows Server 2019.vsphere-clone.ubuntu-2004-test1: Pausing before cleanup of step 'StepAddCDRom'. Press enter to continue.
==> Windows Server 2019.vsphere-clone.ubuntu-2004-test1: Pausing before cleanup of step 'StepConfigureHardware'. Press enter to continue.
==> Windows Server 2019.vsphere-clone.ubuntu-2004-test1: Pausing before cleanup of step 'StepCloneVM'. Press enter to continue.
==> Windows Server 2019.vsphere-clone.ubuntu-2004-test1: Pausing before cleanup of step 'StepRemoteUpload'. Press enter to continue.
==> Windows Server 2019.vsphere-clone.ubuntu-2004-test1: Pausing before cleanup of step 'StepCreateCD'. Press enter to continue.
==> Windows Server 2019.vsphere-clone.ubuntu-2004-test1: Pausing before cleanup of step 'StepConnect'. Press enter to continue.
Build 'Windows Server 2019.vsphere-clone.ubuntu-2004-test1' errored after 28 seconds 640 milliseconds: unexpected EOF
==> Wait completed after 28 seconds 640 milliseconds
==> Some builds didn't complete successfully and had errors:
--> Windows Server 2019.vsphere-clone.ubuntu-2004-test1: unexpected EOF
==> Builds finished but no artifacts were created.
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: panic: runtime error: invalid memory address or nil pointer dereference
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x116af80]
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin:
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: goroutine 120 [running]:
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone.(*WindowsOptions).guiRunOnce(...)
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_customize.go:357
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone.(*WindowsOptions).sysprep(0xc00019e280)
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_customize.go:349 +0x200
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone.(*StepCustomize).identitySettings(0x1?)
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_customize.go:189 +0x1bf
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone.(*StepCustomize).Run(0xc0002fe068, {0x21cb248?, 0xc000a92740?}, {0x25e6dd0, 0xc0004a8090})
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/step_customize.go:159 +0xc5
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-sdk/multistep.(*BasicRunner).Run(0xc0004a8180, {0x25e6900, 0xc000a92740}, {0x25e6dd0, 0xc0004a8090})
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-sdk@v0.3.2/multistep/basic_runner.go:70 +0x2f3
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-sdk/multistep.(*DebugRunner).Run(0xc0004a8150, {0x25e6900, 0xc000a92740}, {0x25e6dd0, 0xc0004a8090})
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-sdk@v0.3.2/multistep/debug_runner.go:84 +0x1b8
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone.(*Builder).Run(0xc00028b800, {0x25e6900, 0xc000a92740}, {0x25e8980?, 0xc0004a8060}, {0x25ca500?, 0xc000686000})
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone/builder.go:159 +0x160c
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-sdk/rpc.(*BuilderServer).Run(0xc000816000, 0x9f7110?, 0xc0009f70f0)
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: github.com/hashicorp/packer-plugin-sdk@v0.3.2/rpc/builder.go:117 +0x1e3
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: reflect.Value.call({0xc00080c240?, 0xc0002fe080?, 0x13?}, {0x21c38f0, 0x4}, {0xc00081eef8, 0x3, 0x3?})
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: reflect/value.go:556 +0x845
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: reflect.Value.Call({0xc00080c240?, 0xc0002fe080?, 0x0?}, {0xc000b43ef8, 0x3, 0x3})
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: reflect/value.go:339 +0xbf
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: net/rpc.(*service).call(0xc000816040, 0x0?, 0x0?, 0xc00012e780, 0xc0000a9400, 0x0?, {0x1d17240?, 0xc0009f70ec?, 0x0?}, {0x1ca5d20, ...}, ...)
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: net/rpc/server.go:381 +0x226
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: created by net/rpc.(*Server).ServeCodec
2023/04/05 17:57:30 packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64 plugin: net/rpc/server.go:478 +0x3fe
2023/04/05 17:57:30 [INFO] (telemetry) ending vsphere-clone.ubuntu-2004-test1
2023/04/05 17:57:30 Waiting on builds to complete...
==> Wait completed after 28 seconds 640 milliseconds
2023/04/05 17:57:30 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2023/04/05 17:57:30 machine readable: Windows Server 2019.vsphere-clone.ubuntu-2004-test1,error []string{"unexpected EOF"}
==> Builds finished but no artifacts were created.
2023/04/05 17:57:30 [INFO] (telemetry) Finalizing.
2023/04/05 17:57:30 /root/.config/packer/plugins/github.com/hashicorp/vsphere/packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64: plugin process exited
2023/04/05 17:57:31 waiting for all plugin processes to complete...
2023/04/05 17:57:31 /usr/bin/packer: plugin process exited
root@linux-vm-automation:~/packer/windows#
Simplified Packer Buildfile
packer { required_version = ">= 1.8.4" required_plugins { vsphere = { version = ">= v1.1.0" source = "github.com/hashicorp/vsphere" } } }
Please open an issue under the packer-plugin-vsphere project.
Opened under hashicorp/packer-plugin-vsphere#269