From c3d793255ecbcb73e7ad099c89f64d6461acd08b Mon Sep 17 00:00:00 2001 From: "Paul Cichonski (pcichons)" Date: Wed, 11 Mar 2020 18:45:05 -0400 Subject: [PATCH] Do not test if NIC is reachable when ssh bastion is required Relates to https://github.com/hashicorp/packer/issues/8866 --- builder/vmware/common/driver_esx5.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/builder/vmware/common/driver_esx5.go b/builder/vmware/common/driver_esx5.go index 109b91967..d2896989e 100644 --- a/builder/vmware/common/driver_esx5.go +++ b/builder/vmware/common/driver_esx5.go @@ -495,6 +495,15 @@ func (d *ESX5Driver) CommHost(state multistep.StateBag) (string, error) { if record["IPAddress"] == "0.0.0.0" { continue } + + // if ssh is going through a bastion, we can't easily check if the nic is reachable on the network + // so just pick the first one that is not 0.0.0.0 + if sshc.SSHBastionHost != "" { + address := record["IPAddress"] + state.Put("vm_address", address) + return address, nil + } + // When multiple NICs are connected to the same network, choose // one that has a route back. This Dial should ensure that. conn, err := net.DialTimeout("tcp", fmt.Sprintf("%s:%d", record["IPAddress"], port), 2*time.Second)