hashicorp / packer-plugin-sdk

Packer Plugin SDK enables building Packer plugins (builders, provisioners, or post-processors) to manage any service providers or custom in-house solutions
Mozilla Public License 2.0
32 stars 44 forks source link

IPv6 connection addresses are invalid, cannot connect via ssh #245

Closed jooola closed 1 month ago

jooola commented 1 month ago

Overview of the Issue

Packer cannot connect to hosts using an ipv6 addresses, The format for the connection address is invalid.

The current construction of the connection address is a simple: fmt.Sprintf("%s:%d", host, port) but this does not work for ipv6, as the host needs to be wrapped between brackets when using ipv6.

I'll open a Pull Request.

Reproduction Steps

Try to run a build against an ipv6 only host.

Packer Plugin SDK version

Current main branch: 1a2b34165aa57b259cf4979fe92758ad6969b001

Operating system and Environment details

Linux, probably also windows.

Log Fragments and crash.log files

==> hcloud.example: Waiting for SSH to become available...
2024/06/06 10:00:10 packer-plugin-hcloud_v1.5.1_x5.0_linux_amd64 plugin: 2024/06/06 10:00:10 [DEBUG] TCP connection to SSH ip/port failed: dial tcp: address 2a01:4f9:c012:e095::1:22: too many colons in address
2024/06/06 10:00:15 packer-plugin-hcloud_v1.5.1_x5.0_linux_amd64 plugin: 2024/06/06 10:00:15 [DEBUG] TCP connection to SSH ip/port failed: dial tcp: address 2a01:4f9:c012:e095::1:22: too many colons in address
2024/06/06 10:00:20 packer-plugin-hcloud_v1.5.1_x5.0_linux_amd64 plugin: 2024/06/06 10:00:20 [DEBUG] TCP connection to SSH ip/port failed: dial tcp: address 2a01:4f9:c012:e095::1:22: too many colons in address
2024/06/06 10:00:25 packer-plugin-hcloud_v1.5.1_x5.0_linux_amd64 plugin: 2024/06/06 10:00:25 [DEBUG] TCP connection to SSH ip/port failed: dial tcp: address 2a01:4f9:c012:e095::1:22: too many colons in address