From 4ff64e4b6ff43b79ce96adc7da3d0a1a763b3fa8 Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Fri, 12 Apr 2024 14:25:12 -0400 Subject: [PATCH] fix: ipv6 rfc2732 To use a literal IPv6 address in a URL, the literal address must be enclosed in "[" and "]" characters. ``` ssh example@[2010:836B:4179::836B:4179] ``` Refer to https://www.ietf.org/rfc/rfc2732. Ref: #333 Signed-off-by: Ryan Johnson --- builder/vsphere/common/step_wait_for_ip.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/builder/vsphere/common/step_wait_for_ip.go b/builder/vsphere/common/step_wait_for_ip.go index 217bf5bd..0b215bcf 100644 --- a/builder/vsphere/common/step_wait_for_ip.go +++ b/builder/vsphere/common/step_wait_for_ip.go @@ -11,6 +11,7 @@ import ( "fmt" "log" "net" + "strings" "time" "github.com/hashicorp/packer-plugin-sdk/multistep" @@ -169,6 +170,12 @@ loop: } else { log.Printf("VM IP is still the same: %s", prevIp) if time.Now().After(stopTime) { + if strings.Contains(ip, ":") { + // To use a literal IPv6 address in a URL the literal address should be enclosed in + // "[" and "]" characters. Refer to https://www.ietf.org/rfc/rfc2732. + // Example: ssh example@[2010:836B:4179::836B:4179] + ip = "["+ip+"]" + } log.Printf("VM IP seems stable enough: %s", ip) return ip, nil }