From e8b3a0e3bf0b080c1aa5f254a4ca4b6ee75f8e5d Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 10 Mar 2021 15:11:53 -0800 Subject: [PATCH] make virtualbox, hyperv, openstack, and parallels builders respect winrm_host by correctly passing communicator config Host() func to commhost instead of just SSHHost --- builder/hyperv/iso/builder.go | 2 +- builder/hyperv/vmcx/builder.go | 2 +- builder/openstack/builder.go | 2 +- builder/parallels/iso/builder.go | 2 +- builder/parallels/pvm/builder.go | 2 +- builder/qemu/comm_config.go | 1 + builder/virtualbox/common/comm_config.go | 3 ++- builder/virtualbox/iso/builder.go | 2 +- builder/virtualbox/ovf/builder.go | 2 +- builder/virtualbox/vm/builder.go | 2 +- 10 files changed, 11 insertions(+), 9 deletions(-) diff --git a/builder/hyperv/iso/builder.go b/builder/hyperv/iso/builder.go index dc2615344..d99de8c15 100644 --- a/builder/hyperv/iso/builder.go +++ b/builder/hyperv/iso/builder.go @@ -294,7 +294,7 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) // configure the communicator ssh, winrm &communicator.StepConnect{ Config: &b.config.SSHConfig.Comm, - Host: hypervcommon.CommHost(b.config.SSHConfig.Comm.SSHHost), + Host: hypervcommon.CommHost(b.config.SSHConfig.Comm.Host()), SSHConfig: b.config.SSHConfig.Comm.SSHConfigFunc(), }, diff --git a/builder/hyperv/vmcx/builder.go b/builder/hyperv/vmcx/builder.go index 48917a251..319bff68b 100644 --- a/builder/hyperv/vmcx/builder.go +++ b/builder/hyperv/vmcx/builder.go @@ -334,7 +334,7 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) // configure the communicator ssh, winrm &communicator.StepConnect{ Config: &b.config.SSHConfig.Comm, - Host: hypervcommon.CommHost(b.config.SSHConfig.Comm.SSHHost), + Host: hypervcommon.CommHost(b.config.SSHConfig.Comm.Host()), SSHConfig: b.config.SSHConfig.Comm.SSHConfigFunc(), }, diff --git a/builder/openstack/builder.go b/builder/openstack/builder.go index 67fb94829..34ff22b0d 100644 --- a/builder/openstack/builder.go +++ b/builder/openstack/builder.go @@ -151,7 +151,7 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) &communicator.StepConnect{ Config: &b.config.RunConfig.Comm, Host: CommHost( - b.config.RunConfig.Comm.SSHHost, + b.config.RunConfig.Comm.Host(), computeClient, b.config.SSHInterface, b.config.SSHIPVersion), diff --git a/builder/parallels/iso/builder.go b/builder/parallels/iso/builder.go index 65e12f330..356ccec76 100644 --- a/builder/parallels/iso/builder.go +++ b/builder/parallels/iso/builder.go @@ -238,7 +238,7 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) }, &communicator.StepConnect{ Config: &b.config.SSHConfig.Comm, - Host: parallelscommon.CommHost(b.config.SSHConfig.Comm.SSHHost), + Host: parallelscommon.CommHost(b.config.SSHConfig.Comm.Host()), SSHConfig: b.config.SSHConfig.Comm.SSHConfigFunc(), }, ¶llelscommon.StepUploadVersion{ diff --git a/builder/parallels/pvm/builder.go b/builder/parallels/pvm/builder.go index 283161201..25c042020 100644 --- a/builder/parallels/pvm/builder.go +++ b/builder/parallels/pvm/builder.go @@ -87,7 +87,7 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) }, &communicator.StepConnect{ Config: &b.config.SSHConfig.Comm, - Host: parallelscommon.CommHost(b.config.SSHConfig.Comm.SSHHost), + Host: parallelscommon.CommHost(b.config.SSHConfig.Comm.Host()), SSHConfig: b.config.SSHConfig.Comm.SSHConfigFunc(), }, ¶llelscommon.StepUploadVersion{ diff --git a/builder/qemu/comm_config.go b/builder/qemu/comm_config.go index 500bba26f..0e90a0a9a 100644 --- a/builder/qemu/comm_config.go +++ b/builder/qemu/comm_config.go @@ -48,6 +48,7 @@ func (c *CommConfig) Prepare(ctx *interpolate.Context) (warnings []string, errs if c.Comm.SSHHost == "" && c.SkipNatMapping { c.Comm.SSHHost = "127.0.0.1" + c.Comm.WinRMHost = "127.0.0.1" } if c.HostPortMin == 0 { diff --git a/builder/virtualbox/common/comm_config.go b/builder/virtualbox/common/comm_config.go index 44e428bb2..d635b17f2 100644 --- a/builder/virtualbox/common/comm_config.go +++ b/builder/virtualbox/common/comm_config.go @@ -50,8 +50,9 @@ func (c *CommConfig) Prepare(ctx *interpolate.Context) []error { c.SkipNatMapping = c.SSHSkipNatMapping } - if c.Comm.SSHHost == "" { + if c.Comm.Host() == "" { c.Comm.SSHHost = "127.0.0.1" + c.Comm.WinRMHost = "127.0.0.1" } if c.HostPortMin == 0 { diff --git a/builder/virtualbox/iso/builder.go b/builder/virtualbox/iso/builder.go index 0643370de..874033721 100644 --- a/builder/virtualbox/iso/builder.go +++ b/builder/virtualbox/iso/builder.go @@ -449,7 +449,7 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) }, &communicator.StepConnect{ Config: &b.config.CommConfig.Comm, - Host: vboxcommon.CommHost(b.config.CommConfig.Comm.SSHHost), + Host: vboxcommon.CommHost(b.config.CommConfig.Comm.Host()), SSHConfig: b.config.CommConfig.Comm.SSHConfigFunc(), SSHPort: vboxcommon.CommPort, WinRMPort: vboxcommon.CommPort, diff --git a/builder/virtualbox/ovf/builder.go b/builder/virtualbox/ovf/builder.go index b6bffb100..fb0a53965 100644 --- a/builder/virtualbox/ovf/builder.go +++ b/builder/virtualbox/ovf/builder.go @@ -130,7 +130,7 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) }, &communicator.StepConnect{ Config: &b.config.CommConfig.Comm, - Host: vboxcommon.CommHost(b.config.CommConfig.Comm.SSHHost), + Host: vboxcommon.CommHost(b.config.CommConfig.Comm.Host()), SSHConfig: b.config.CommConfig.Comm.SSHConfigFunc(), SSHPort: vboxcommon.CommPort, WinRMPort: vboxcommon.CommPort, diff --git a/builder/virtualbox/vm/builder.go b/builder/virtualbox/vm/builder.go index cc93ae3ed..b762e65f7 100644 --- a/builder/virtualbox/vm/builder.go +++ b/builder/virtualbox/vm/builder.go @@ -114,7 +114,7 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) }, &communicator.StepConnect{ Config: &b.config.CommConfig.Comm, - Host: vboxcommon.CommHost(b.config.CommConfig.Comm.SSHHost), + Host: vboxcommon.CommHost(b.config.CommConfig.Comm.Host()), SSHConfig: b.config.CommConfig.Comm.SSHConfigFunc(), SSHPort: vboxcommon.CommPort, WinRMPort: vboxcommon.CommPort,