Sha256: 2ce435649d03e0d5e5d8b85902ea41f193a00a7ce7a097165915aa1f3bee6f2b

Contents?: true

Size: 979 Bytes

Versions: 11

Compression:

Stored size: 979 Bytes

Contents

module Fog
module Compute
class AWS
class Server
  
  def setup(credentials = {})
    requires :ssh_ip_address, :username
    
    commands = [
      %{mkdir .ssh},
      %{passwd -l #{username}},
      %{echo "#{Fog::JSON.encode(Fog::JSON.sanitize(attributes))}" >> ~/attributes.json}
    ]
    if public_key
      commands << %{echo "#{public_key}" >> ~/.ssh/authorized_keys}
    end

    tries      = 5
    sleep_secs = 5
    
    begin      
      Nucleon::Util::SSH.session(ssh_ip_address, username, ssh_port, private_key_path, true)
      results = Nucleon::Util::SSH.exec(ssh_ip_address, username, commands)
            
    rescue Net::SSH::HostKeyMismatch => error
      error.remember_host!
      sleep 0.2
      reset = true
      retry
      
    rescue Net::SSH::ConnectionTimeout, Net::SSH::Disconnect => error     
      if tries > 1
        sleep(sleep_secs)
        
        tries -= 1
        reset  = true
        retry
      end
    end
  end
end
end
end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
corl-0.5.1 lib/core/mod/fog_aws_server.rb
corl-0.5.0 lib/core/mod/fog_aws_server.rb
corl-0.4.29 lib/core/mod/fog_aws_server.rb
corl-0.4.28 lib/core/mod/fog_aws_server.rb
corl-0.4.27 lib/core/mod/fog_aws_server.rb
corl-0.4.26 lib/core/mod/fog_aws_server.rb
corl-0.4.25 lib/core/mod/fog_aws_server.rb
corl-0.4.24 lib/core/mod/fog_aws_server.rb
corl-0.4.23 lib/core/mod/fog_aws_server.rb
corl-0.4.22 lib/core/mod/fog_aws_server.rb
corl-0.4.21 lib/core/mod/fog_aws_server.rb