Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customize ssh_timeout and ssh_retries #58

Merged
merged 4 commits into from
Aug 12, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,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 @@ -196,6 +208,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