builder.aws: use key pair from comm struct
This commit is contained in:
parent
77a57f0354
commit
3a4bb26150
|
@ -57,9 +57,8 @@ type RunConfig struct {
|
||||||
WindowsPasswordTimeout time.Duration `mapstructure:"windows_password_timeout"`
|
WindowsPasswordTimeout time.Duration `mapstructure:"windows_password_timeout"`
|
||||||
|
|
||||||
// Communicator settings
|
// Communicator settings
|
||||||
Comm communicator.Config `mapstructure:",squash"`
|
Comm communicator.Config `mapstructure:",squash"`
|
||||||
SSHKeyPairName string `mapstructure:"ssh_keypair_name"`
|
SSHInterface string `mapstructure:"ssh_interface"`
|
||||||
SSHInterface string `mapstructure:"ssh_interface"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
func (c *RunConfig) Prepare(ctx *interpolate.Context) []error {
|
||||||
|
@ -67,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.SSHKeyPairName == "" && c.TemporaryKeyPairName == "" &&
|
if c.Comm.SSHKeyPair == "" && 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())
|
||||||
|
@ -93,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.SSHKeyPairName != "" {
|
if c.Comm.SSHKeyPair != "" {
|
||||||
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 {
|
||||||
|
|
Loading…
Reference in New Issue