Skip to content

Commit

Permalink
Merge pull request #58 from ekrupnik/ssh-config
Browse files Browse the repository at this point in the history
Customize ssh_timeout and ssh_retries
  • Loading branch information
sethvargo committed Aug 12, 2014
2 parents a32c0dd + 6dd2e9f commit 462e7a1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ Path to the private SSH key used to connect to the instance.

The default is unset, or `nil`.

### <a name="config-ssh-timeout"></a> ssh\_timeout

The number of seconds to sleep before trying to SSH again.

The default is `1`.

### <a name="config-ssh-retries"></a> ssh\_retries

The number of times to retry SSH-ing into the instance.

The default is `3`.

### <a name="config-subnet-id"></a> subnet\_id

The EC2 [subnet][subnet_docs] to use.
Expand Down Expand Up @@ -205,6 +217,8 @@ driver:
require_chef_omnibus: true
subnet_id: subnet-6d6...
iam_profile_name: chef-client
ssh_timeout: 10
ssh_retries: 5

platforms:
- name: ubuntu-12.04
Expand Down
11 changes: 9 additions & 2 deletions lib/kitchen/driver/ec2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class Ec2 < Kitchen::Driver::SSHBase
end

default_config :interface, nil
default_config :ssh_timeout, 1
default_config :ssh_retries, 3

required_config :aws_access_key_id
required_config :aws_secret_access_key
Expand All @@ -75,8 +77,11 @@ def create(state)
server.wait_for { print '.'; ready? }
print '(server ready)'
state[:hostname] = hostname(server)
wait_for_sshd(state[:hostname], config[:username])
print '(ssh ready)\n'
wait_for_sshd(state[:hostname], config[:username], {
:ssh_timeout => config[:ssh_timeout],
:ssh_retries => config[:ssh_retries]
})
print "(ssh ready)\n"
debug("ec2:create '#{state[:hostname]}'")
rescue Fog::Errors::Error, Excon::Errors::Error => ex
raise ActionFailed, ex.message
Expand Down Expand Up @@ -141,6 +146,8 @@ def debug_server_config
debug("ec2:key_name '#{config[:aws_ssh_key_id]}'")
debug("ec2:subnet_id '#{config[:subnet_id]}'")
debug("ec2:iam_profile_name '#{config[:iam_profile_name]}'")
debug("ec2:ssh_timeout '#{config[:ssh_timeout]}'")
debug("ec2:ssh_retries '#{config[:ssh_retries]}'")
end

def amis
Expand Down

0 comments on commit 462e7a1

Please sign in to comment.