Support 'http_host' parameter (fix #184)

This commit is contained in:
Michael Kuzmin 2018-12-23 20:16:49 +03:00
parent 9cad0b7b66
commit be84a39aa0
3 changed files with 10 additions and 4 deletions

View File

@ -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{},

View File

@ -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) {

View File

@ -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{},