Merge pull request #5 from YuSungDuk/support_ncloud
Use `PublicIp` for communicator
This commit is contained in:
commit
903c248c52
@ -48,7 +48,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||||||
NewStepCreatePublicIPInstance(conn, ui, b.config),
|
NewStepCreatePublicIPInstance(conn, ui, b.config),
|
||||||
&communicator.StepConnectSSH{
|
&communicator.StepConnectSSH{
|
||||||
Config: &b.config.Comm,
|
Config: &b.config.Comm,
|
||||||
Host: SSHHost,
|
Host: func(stateBag multistep.StateBag) (string, error) {
|
||||||
|
return stateBag.Get("PublicIP").(string), nil
|
||||||
|
},
|
||||||
SSHConfig: SSHConfig(b.config.Comm.SSHUsername),
|
SSHConfig: SSHConfig(b.config.Comm.SSHUsername),
|
||||||
},
|
},
|
||||||
&common.StepProvision{},
|
&common.StepProvision{},
|
||||||
@ -68,7 +70,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||||||
&communicator.StepConnectWinRM{
|
&communicator.StepConnectWinRM{
|
||||||
Config: &b.config.Comm,
|
Config: &b.config.Comm,
|
||||||
Host: func(stateBag multistep.StateBag) (string, error) {
|
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) {
|
WinRMConfig: func(state multistep.StateBag) (*communicator.WinRMConfig, error) {
|
||||||
return &communicator.WinRMConfig{
|
return &communicator.WinRMConfig{
|
||||||
|
@ -6,11 +6,6 @@ import (
|
|||||||
"golang.org/x/crypto/ssh"
|
"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
|
// SSHConfig returns a function that can be used for the SSH communicator
|
||||||
// config for connecting to the specified host via SSH
|
// config for connecting to the specified host via SSH
|
||||||
func SSHConfig(username string) func(multistep.StateBag) (*ssh.ClientConfig, error) {
|
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)
|
publicIPInstance, err := s.CreatePublicIPInstance(serverInstanceNo)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
switch s.Config.Comm.Type {
|
state.Put("PublicIP", publicIPInstance.PublicIP)
|
||||||
case "ssh":
|
|
||||||
state.Put("SSHHost", publicIPInstance.PublicIP)
|
|
||||||
case "winrm":
|
|
||||||
state.Put("WinRMHost", publicIPInstance.PublicIP)
|
|
||||||
}
|
|
||||||
|
|
||||||
state.Put("PublicIPInstance", publicIPInstance)
|
state.Put("PublicIPInstance", publicIPInstance)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user