Takes static WinRM config into consideration

This commit is contained in:
Peter Pribula 2019-04-30 22:26:40 +02:00
parent 02b6e7f3de
commit 778dda9fe0
1 changed files with 6 additions and 5 deletions

View File

@ -71,7 +71,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
},
&communicator.StepConnect{
Config: &b.config.Comm,
Host: commHost(b.config.Comm.SSHHost),
Host: commHost(b.config.Comm.Host()),
SSHConfig: b.config.Comm.SSHConfigFunc(),
},
&common.StepProvision{},
@ -98,11 +98,12 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
return artifact, nil
}
// Returns ssh_host config parameter when set, otherwise gets the host IP from running VM
func commHost(sshHost string) func(state multistep.StateBag) (string, error) {
if sshHost != "" {
// Returns ssh_host or winrm_host (see communicator.Config.Host) config
// parameter when set, otherwise gets the host IP from running VM
func commHost(host string) func(state multistep.StateBag) (string, error) {
if host != "" {
return func(state multistep.StateBag) (string, error) {
return sshHost, nil
return host, nil
}
}
return getVMIP