Use `PublicIp` for communicator
This commit is contained in:
parent
e57a8161e0
commit
6b40c726e0
|
@ -47,8 +47,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
NewStepGetRootPassword(conn, ui),
|
||||
NewStepCreatePublicIPInstance(conn, ui, b.config),
|
||||
&communicator.StepConnectSSH{
|
||||
Config: &b.config.Comm,
|
||||
Host: SSHHost,
|
||||
Config: &b.config.Comm,
|
||||
Host: func(stateBag multistep.StateBag) (string, error) {
|
||||
return stateBag.Get("PublicIP").(string), nil
|
||||
},
|
||||
SSHConfig: SSHConfig(b.config.Comm.SSHUsername),
|
||||
},
|
||||
&common.StepProvision{},
|
||||
|
@ -68,7 +70,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
&communicator.StepConnectWinRM{
|
||||
Config: &b.config.Comm,
|
||||
Host: func(stateBag multistep.StateBag) (string, error) {
|
||||
return stateBag.Get("WinRMHost").(string), nil
|
||||
return stateBag.Get("PublicIP").(string), nil
|
||||
},
|
||||
WinRMConfig: func(state multistep.StateBag) (*communicator.WinRMConfig, error) {
|
||||
return &communicator.WinRMConfig{
|
||||
|
|
|
@ -6,11 +6,6 @@ import (
|
|||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
func SSHHost(state multistep.StateBag) (string, error) {
|
||||
host := state.Get("SSHHost").(string)
|
||||
return host, nil
|
||||
}
|
||||
|
||||
// SSHConfig returns a function that can be used for the SSH communicator
|
||||
// config for connecting to the specified host via SSH
|
||||
func SSHConfig(username string) func(multistep.StateBag) (*ssh.ClientConfig, error) {
|
||||
|
|
|
@ -91,13 +91,7 @@ func (s *StepCreatePublicIPInstance) Run(state multistep.StateBag) multistep.Ste
|
|||
|
||||
publicIPInstance, err := s.CreatePublicIPInstance(serverInstanceNo)
|
||||
if err == nil {
|
||||
switch s.Config.Comm.Type {
|
||||
case "ssh":
|
||||
state.Put("SSHHost", publicIPInstance.PublicIP)
|
||||
case "winrm":
|
||||
state.Put("WinRMHost", publicIPInstance.PublicIP)
|
||||
}
|
||||
|
||||
state.Put("PublicIP", publicIPInstance.PublicIP)
|
||||
state.Put("PublicIPInstance", publicIPInstance)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue