Commit dbbf1047 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Merge branch 'b-config-handshake'

parents 8b52fa52 8d0904e2
...@@ -22,6 +22,7 @@ type Config struct { ...@@ -22,6 +22,7 @@ type Config struct {
SSHPrivateKey string `mapstructure:"ssh_private_key_file"` SSHPrivateKey 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"`
SSHHandshakeAttempts int `mapstructure:"ssh_handshake_attempts"`
// WinRM // WinRM
WinRMUser string `mapstructure:"winrm_username"` WinRMUser string `mapstructure:"winrm_username"`
...@@ -72,6 +73,10 @@ func (c *Config) prepareSSH(ctx *interpolate.Context) []error { ...@@ -72,6 +73,10 @@ func (c *Config) prepareSSH(ctx *interpolate.Context) []error {
c.SSHTimeout = 5 * time.Minute c.SSHTimeout = 5 * time.Minute
} }
if c.SSHHandshakeAttempts == 0 {
c.SSHHandshakeAttempts = 10
}
// Validation // Validation
var errs []error var errs []error
if c.SSHUsername == "" { if c.SSHUsername == "" {
......
...@@ -149,8 +149,10 @@ func (s *StepConnectSSH) waitForSSH(state multistep.StateBag, cancel <-chan stru ...@@ -149,8 +149,10 @@ func (s *StepConnectSSH) waitForSSH(state multistep.StateBag, cancel <-chan stru
handshakeAttempts += 1 handshakeAttempts += 1
} }
if handshakeAttempts < 10 { if handshakeAttempts < s.Config.SSHHandshakeAttempts {
// Try to connect via SSH a handful of times // Try to connect via SSH a handful of times. We sleep here
// so we don't get a ton of authentication errors back to back.
time.Sleep(2 * time.Second)
continue continue
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment