config.Comm.SSHKeyPair => SSHKeyPairName
This commit is contained in:
parent
3a4bb26150
commit
9a9b82715b
|
@ -21,7 +21,7 @@ func (s *stepAttachKeyPair) Run(_ context.Context, state multistep.StateBag) mul
|
||||||
config := state.Get("config").(Config)
|
config := state.Get("config").(Config)
|
||||||
instance := state.Get("instance").(*ecs.InstanceAttributesType)
|
instance := state.Get("instance").(*ecs.InstanceAttributesType)
|
||||||
timeoutPoint := time.Now().Add(120 * time.Second)
|
timeoutPoint := time.Now().Add(120 * time.Second)
|
||||||
keyPairName := config.Comm.SSHKeyPair
|
keyPairName := config.Comm.SSHKeyPairName
|
||||||
if keyPairName == "" {
|
if keyPairName == "" {
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ func (s *stepAttachKeyPair) Cleanup(state multistep.StateBag) {
|
||||||
config := state.Get("config").(Config)
|
config := state.Get("config").(Config)
|
||||||
ui := state.Get("ui").(packer.Ui)
|
ui := state.Get("ui").(packer.Ui)
|
||||||
instance := state.Get("instance").(*ecs.InstanceAttributesType)
|
instance := state.Get("instance").(*ecs.InstanceAttributesType)
|
||||||
keyPairName := config.Comm.SSHKeyPair
|
keyPairName := config.Comm.SSHKeyPairName
|
||||||
if keyPairName == "" {
|
if keyPairName == "" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ func (s *stepConfigAlicloudKeyPair) Run(_ context.Context, state multistep.State
|
||||||
return multistep.ActionHalt
|
return multistep.ActionHalt
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Comm.SSHKeyPair = s.KeyPairName
|
config.Comm.SSHKeyPairName = s.KeyPairName
|
||||||
config.Comm.SSHPrivateKey = privateKeyBytes
|
config.Comm.SSHPrivateKey = privateKeyBytes
|
||||||
|
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
|
@ -77,7 +77,7 @@ func (s *stepConfigAlicloudKeyPair) Run(_ context.Context, state multistep.State
|
||||||
s.keyName = s.TemporaryKeyPairName
|
s.keyName = s.TemporaryKeyPairName
|
||||||
|
|
||||||
// Set some state data for use in future steps
|
// Set some state data for use in future steps
|
||||||
config.Comm.SSHKeyPair = s.keyName
|
config.Comm.SSHKeyPairName = s.keyName
|
||||||
config.Comm.SSHPrivateKey = []byte(keyResp.PrivateKeyBody)
|
config.Comm.SSHPrivateKey = []byte(keyResp.PrivateKeyBody)
|
||||||
|
|
||||||
// If we're in debug mode, output the private key to the working
|
// If we're in debug mode, output the private key to the working
|
||||||
|
|
|
@ -66,7 +66,7 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
||||||
// ssh_private_key_file, then create a temporary one, but only if the
|
// ssh_private_key_file, then create a temporary one, but only if the
|
||||||
// temporary_key_pair_name has not been provided and we are not using
|
// temporary_key_pair_name has not been provided and we are not using
|
||||||
// ssh_password.
|
// ssh_password.
|
||||||
if c.Comm.SSHKeyPair == "" && c.TemporaryKeyPairName == "" &&
|
if c.Comm.SSHKeyPairName == "" && c.TemporaryKeyPairName == "" &&
|
||||||
c.Comm.SSHPrivateKeyFile == "" && c.Comm.SSHPassword == "" {
|
c.Comm.SSHPrivateKeyFile == "" && c.Comm.SSHPassword == "" {
|
||||||
|
|
||||||
c.TemporaryKeyPairName = fmt.Sprintf("packer_%s", uuid.TimeOrderedUUID())
|
c.TemporaryKeyPairName = fmt.Sprintf("packer_%s", uuid.TimeOrderedUUID())
|
||||||
|
@ -92,7 +92,7 @@ func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
||||||
errs = append(errs, fmt.Errorf("Unknown interface type: %s", c.SSHInterface))
|
errs = append(errs, fmt.Errorf("Unknown interface type: %s", c.SSHInterface))
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Comm.SSHKeyPair != "" {
|
if c.Comm.SSHKeyPairName != "" {
|
||||||
if c.Comm.Type == "winrm" && c.Comm.WinRMPassword == "" && c.Comm.SSHPrivateKeyFile == "" {
|
if c.Comm.Type == "winrm" && c.Comm.WinRMPassword == "" && c.Comm.SSHPrivateKeyFile == "" {
|
||||||
errs = append(errs, fmt.Errorf("ssh_private_key_file must be provided to retrieve the winrm password when using ssh_keypair_name."))
|
errs = append(errs, fmt.Errorf("ssh_private_key_file must be provided to retrieve the winrm password when using ssh_keypair_name."))
|
||||||
} else if c.Comm.SSHPrivateKeyFile == "" && !c.Comm.SSHAgentAuth {
|
} else if c.Comm.SSHPrivateKeyFile == "" && !c.Comm.SSHAgentAuth {
|
||||||
|
|
|
@ -39,14 +39,14 @@ func (s *StepKeyPair) Run(_ context.Context, state multistep.StateBag) multistep
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.Comm.SSHAgentAuth && s.Comm.SSHKeyPair == "" {
|
if s.Comm.SSHAgentAuth && s.Comm.SSHKeyPairName == "" {
|
||||||
ui.Say("Using SSH Agent with key pair in Source AMI")
|
ui.Say("Using SSH Agent with key pair in Source AMI")
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.Comm.SSHAgentAuth && s.Comm.SSHKeyPair != "" {
|
if s.Comm.SSHAgentAuth && s.Comm.SSHKeyPairName != "" {
|
||||||
ui.Say(fmt.Sprintf("Using SSH Agent for existing key pair %s", s.Comm.SSHKeyPair))
|
ui.Say(fmt.Sprintf("Using SSH Agent for existing key pair %s", s.Comm.SSHKeyPairName))
|
||||||
state.Put("keyPair", s.Comm.SSHKeyPair)
|
state.Put("keyPair", s.Comm.SSHKeyPairName)
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ func (s *StepKeyPair) Run(_ context.Context, state multistep.StateBag) multistep
|
||||||
s.doCleanup = true
|
s.doCleanup = true
|
||||||
|
|
||||||
// Set some data for use in future steps
|
// Set some data for use in future steps
|
||||||
s.Comm.SSHKeyPair = s.TemporaryKeyPairName
|
s.Comm.SSHKeyPairName = s.TemporaryKeyPairName
|
||||||
s.Comm.SSHPrivateKey = []byte(*keyResp.KeyMaterial)
|
s.Comm.SSHPrivateKey = []byte(*keyResp.KeyMaterial)
|
||||||
|
|
||||||
// If we're in debug mode, output the private key to the working
|
// If we're in debug mode, output the private key to the working
|
||||||
|
|
|
@ -39,7 +39,7 @@ func (s *StepKeyPair) Run(_ context.Context, state multistep.StateBag) multistep
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Comm.SSHPrivateKey = privateKeyBytes
|
config.Comm.SSHPrivateKey = privateKeyBytes
|
||||||
config.Comm.SSHKeyPair = s.KeyPairName
|
config.Comm.SSHKeyPairName = s.KeyPairName
|
||||||
|
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
@ -51,13 +51,13 @@ func (s *StepKeyPair) Run(_ context.Context, state multistep.StateBag) multistep
|
||||||
|
|
||||||
if s.SSHAgentAuth && s.KeyPairName != "" {
|
if s.SSHAgentAuth && s.KeyPairName != "" {
|
||||||
ui.Say(fmt.Sprintf("Using SSH Agent for existing key pair %s", s.KeyPairName))
|
ui.Say(fmt.Sprintf("Using SSH Agent for existing key pair %s", s.KeyPairName))
|
||||||
config.Comm.SSHKeyPair = ""
|
config.Comm.SSHKeyPairName = ""
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.TemporaryKeyPairName == "" {
|
if s.TemporaryKeyPairName == "" {
|
||||||
ui.Say("Not using temporary keypair")
|
ui.Say("Not using temporary keypair")
|
||||||
config.Comm.SSHKeyPair = ""
|
config.Comm.SSHKeyPairName = ""
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ func (s *StepKeyPair) Run(_ context.Context, state multistep.StateBag) multistep
|
||||||
s.doCleanup = true
|
s.doCleanup = true
|
||||||
|
|
||||||
// Set some state data for use in future steps
|
// Set some state data for use in future steps
|
||||||
config.Comm.SSHKeyPair = s.TemporaryKeyPairName
|
config.Comm.SSHKeyPairName = s.TemporaryKeyPairName
|
||||||
config.Comm.SSHPrivateKey = []byte(keypair.PrivateKey)
|
config.Comm.SSHPrivateKey = []byte(keypair.PrivateKey)
|
||||||
|
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
|
|
|
@ -107,7 +107,7 @@ func (s *StepRunSourceServer) Run(_ context.Context, state multistep.StateBag) m
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add keypair to the server create options.
|
// Add keypair to the server create options.
|
||||||
keyName := config.Comm.SSHKeyPair
|
keyName := config.Comm.SSHKeyPairName
|
||||||
if keyName != "" {
|
if keyName != "" {
|
||||||
serverOptsExt = keypairs.CreateOptsExt{
|
serverOptsExt = keypairs.CreateOptsExt{
|
||||||
CreateOptsBuilder: serverOptsExt,
|
CreateOptsBuilder: serverOptsExt,
|
||||||
|
|
|
@ -29,7 +29,7 @@ type Config struct {
|
||||||
SSHPassword string `mapstructure:"ssh_password"`
|
SSHPassword string `mapstructure:"ssh_password"`
|
||||||
SSHPublicKey []byte `mapstructure:"ssh_public_key"`
|
SSHPublicKey []byte `mapstructure:"ssh_public_key"`
|
||||||
SSHPrivateKey []byte `mapstructure:"ssh_private_key"`
|
SSHPrivateKey []byte `mapstructure:"ssh_private_key"`
|
||||||
SSHKeyPair string `mapstructure:"ssh_keypair_name"`
|
SSHKeyPairName string `mapstructure:"ssh_keypair_name"`
|
||||||
SSHPrivateKeyFile string `mapstructure:"ssh_private_key_file"`
|
SSHPrivateKeyFile string `mapstructure:"ssh_private_key_file"`
|
||||||
SSHPty bool `mapstructure:"ssh_pty"`
|
SSHPty bool `mapstructure:"ssh_pty"`
|
||||||
SSHTimeout time.Duration `mapstructure:"ssh_timeout"`
|
SSHTimeout time.Duration `mapstructure:"ssh_timeout"`
|
||||||
|
|
Loading…
Reference in New Issue