From be84a39aa0c4c50a89193acec90471ef45c336fb Mon Sep 17 00:00:00 2001 From: Michael Kuzmin Date: Sun, 23 Dec 2018 20:16:49 +0300 Subject: [PATCH] Support 'http_host' parameter (fix #184) --- clone/builder.go | 2 +- common/config_ssh.go | 10 ++++++++-- iso/builder.go | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/clone/builder.go b/clone/builder.go index 757e9b2c5..ec3356709 100644 --- a/clone/builder.go +++ b/clone/builder.go @@ -58,7 +58,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe &common.StepWaitForIp{}, &communicator.StepConnect{ Config: &b.config.Comm, - Host: common.CommHost, + Host: common.CommHost(b.config.Comm.SSHHost), SSHConfig: common.SshConfig, }, &packerCommon.StepProvision{}, diff --git a/common/config_ssh.go b/common/config_ssh.go index cd9fdba1c..e1df13e54 100644 --- a/common/config_ssh.go +++ b/common/config_ssh.go @@ -9,8 +9,14 @@ import ( "io/ioutil" ) -func CommHost(state multistep.StateBag) (string, error) { - return state.Get("ip").(string), nil +func CommHost(host string) func(multistep.StateBag) (string, error) { + return func(state multistep.StateBag) (string, error) { + if host != "" { + return host, nil + } else { + return state.Get("ip").(string), nil + } + } } func SshConfig(state multistep.StateBag) (*ssh.ClientConfig, error) { diff --git a/iso/builder.go b/iso/builder.go index cb21ef77d..991ea86ee 100644 --- a/iso/builder.go +++ b/iso/builder.go @@ -80,7 +80,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe &common.StepWaitForIp{}, &communicator.StepConnect{ Config: &b.config.Comm, - Host: common.CommHost, + Host: common.CommHost(b.config.Comm.SSHHost), SSHConfig: common.SshConfig, }, &packerCommon.StepProvision{},