Closed pinjic closed 4 months ago
I ran into the same issue and I have a working "fix" (this could be fixed in packer itself, or elsewhere in the code then where I inserted it).
The issue is somewhere I assume in the packer code packer is plugging whatever IP string it gets into a function that attempts to parse the IP according to: https://www.rfc-editor.org/rfc/rfc2732 . The fix is to introduce [] around the IPv6 address at some step in the process.
In this example I just do a naive check if a ":" is in the string and concatenate the required brackets around it; this results in a successful connection:
==> centos_stream9.vsphere-iso.image: IP address: [2605:90f4:0:53:250:56ff:fea5:571f] ==> centos_stream9.vsphere-iso.image: Using SSH communicator to connect: [2605:90f4:0:53:250:56ff:fea5:571f] 2024/02/01 12:14:04 packer-plugin-vsphere plugin: 2024/02/01 12:14:04 [INFO] Waiting for SSH, up to timeout: 5m0s ==> centos_stream9.vsphere-iso.image: Waiting for SSH to become available... 2024/02/01 12:14:04 packer-plugin-vsphere plugin: 2024/02/01 12:14:04 [INFO] Attempting SSH connection to [2605:90f4:0:53:250:56ff:fea5:571f]:22... 2024/02/01 12:14:04 packer-plugin-vsphere plugin: 2024/02/01 12:14:04 [DEBUG] reconnecting to TCP connection for SSH 2024/02/01 12:14:04 packer-plugin-vsphere plugin: 2024/02/01 12:14:04 [DEBUG] handshaking with SSH 2024/02/01 12:14:05 packer-plugin-vsphere plugin: 2024/02/01 12:14:05 [DEBUG] handshake complete! 2024/02/01 12:14:05 packer-plugin-vsphere plugin: 2024/02/01 12:14:05 [DEBUG] Opening new ssh session 2024/02/01 12:14:05 packer-plugin-vsphere plugin: 2024/02/01 12:14:05 [INFO] agent forwarding enabled ==> centos_stream9.vsphere-iso.image: Connected to SSH!
I believe (but have not tried) that this could also be fixed in this portion: https://github.com/hashicorp/packer-plugin-vsphere/blob/c76697aef7159648fd1ed343f74f0201ea5c29d7/builder/vsphere/driver/vm.go#L718 by adding some manner of check and then properly formatting the address string if an IPv6 address is detected.
If wanted I could make a PR for whichever option is preferred (even if it's "it should be handled in packer").
@nywilken and @lbajolet-hashicorp for comment. ☝🏻
Overview of the Issue
Whilst creating IPv6-only packer images, we ran into the following problems:
Packer was still waiting/polling for an assigned IP address to the VM, although it had already received an IPv6 address.
This was solved by assigning an IPv6 range (e.g.
2001:db8:dead:beef::/64
) to theip_wait_address
variable inside thesource "vsphere-iso" "[name]"
stanza. This was necessary due to the vSphere ISO builder defaulting to IPv4: https://developer.hashicorp.com/packer/integrations/hashicorp/vsphere/latest/components/builder/vsphere-iso#wait-configurationPacker was still waiting/polling for SSH to become available, even after passing the IP check.
Still unresolved. The SSH wait seems to continue using the detected IP address of the VM, but doesn't work around the implications of the address being an IPv6 address:
Might be the same problem as described in https://github.com/hashicorp/packer/issues/9360.
Reproduction Steps
ip_wait_address
and assign it an IPv6 range as a string insidepacker/vsphere-iso_basic_ubuntu.pkr.hcl
.PACKER_LOG=1 packer build
. It will wait/poll for SSH to become available indefinitely.Packer Version
Packer v1.9.4
Plugin Version and Builders
Plugin: packer-plugin-vsphere_v1.2.2_x5.0_linux_amd64
Builder: vsphere-iso
VMware vSphere Version
7.0.3
Guest Operating System
Both tested with Ubuntu 22.04 LTS and Ubuntu 20.04 LTS.
Simplified Packer Buildfile
ip_wait_address
added in thesource "vsphere-iso" "[name]"
stanza.Operating System and Environment Details
Packer was run from my Ubuntu 22.04 LTS desktop.