Fix for issue #2972 - Implemented ssh_host for virtualbox builders (#3617)

This commit is contained in:
Lamoni Finlayson 2016-08-24 09:30:26 -07:00 committed by Rickard von Essen
parent 27cdd4480a
commit d02b106a16
4 changed files with 10 additions and 4 deletions

View File

@ -7,8 +7,10 @@ import (
gossh "golang.org/x/crypto/ssh"
)
func CommHost(state multistep.StateBag) (string, error) {
return "127.0.0.1", nil
func CommHost(host string) func(multistep.StateBag) (string, error) {
return func(state multistep.StateBag) (string, error) {
return host, nil
}
}
func SSHPort(state multistep.StateBag) (int, error) {

View File

@ -21,6 +21,10 @@ type SSHConfig struct {
}
func (c *SSHConfig) Prepare(ctx *interpolate.Context) []error {
if c.Comm.SSHHost == "" {
c.Comm.SSHHost = "127.0.0.1"
}
if c.SSHHostPortMin == 0 {
c.SSHHostPortMin = 2222
}

View File

@ -235,7 +235,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
},
&communicator.StepConnect{
Config: &b.config.SSHConfig.Comm,
Host: vboxcommon.CommHost,
Host: vboxcommon.CommHost(b.config.SSHConfig.Comm.SSHHost),
SSHConfig: vboxcommon.SSHConfigFunc(b.config.SSHConfig),
SSHPort: vboxcommon.SSHPort,
},

View File

@ -104,7 +104,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
},
&communicator.StepConnect{
Config: &b.config.SSHConfig.Comm,
Host: vboxcommon.CommHost,
Host: vboxcommon.CommHost(b.config.SSHConfig.Comm.SSHHost),
SSHConfig: vboxcommon.SSHConfigFunc(b.config.SSHConfig),
SSHPort: vboxcommon.SSHPort,
},