mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
parent
c570a6bb10
commit
6ee69750f6
2 changed files with 12 additions and 4 deletions
|
@ -152,7 +152,7 @@ module Fog
|
|||
def setup(credentials = {})
|
||||
requires :identity, :ip_address, :username
|
||||
require 'json'
|
||||
sleep(10) # takes a bit before EC2 instances will play nice
|
||||
|
||||
commands = [
|
||||
%{mkdir .ssh},
|
||||
%{passwd -l root},
|
||||
|
@ -161,7 +161,16 @@ module Fog
|
|||
if public_key
|
||||
commands << %{echo "#{public_key}" >> ~/.ssh/authorized_keys}
|
||||
end
|
||||
Fog::SSH.new(ip_address, username, credentials).run(commands)
|
||||
# allow some retries over the first 120 seconds because aws is weird
|
||||
Timeout::timeout(120) do
|
||||
begin
|
||||
Timeout::timeout(4) do
|
||||
Fog::SSH.new(ip_address, username, credentials).run(commands)
|
||||
end
|
||||
rescue Net::SSH::AuthenticationFailed, Timeout::Error
|
||||
retry
|
||||
end
|
||||
end
|
||||
rescue Errno::ECONNREFUSED => e
|
||||
sleep(1)
|
||||
retry
|
||||
|
|
|
@ -42,8 +42,7 @@ module Fog
|
|||
require 'net/ssh'
|
||||
@address = address
|
||||
@username = username
|
||||
@options = options.merge(:paranoid => false)
|
||||
@options.merge(:verbose => true)
|
||||
@options = { :paranoid => false }.merge(options)
|
||||
end
|
||||
|
||||
def run(commands)
|
||||
|
|
Loading…
Add table
Reference in a new issue