def run
require 'fog'
require 'highline'
require 'net/ssh/multi'
require 'readline'
$stdout.sync = true
connection = Fog::AWS::EC2.new(
:aws_access_key_id => Chef::Config[:knife][:aws_access_key_id],
:aws_secret_access_key => Chef::Config[:knife][:aws_secret_access_key],
:region => config[:region]
)
server = connection.servers.create(
:image_id => config[:image],
:groups => config[:security_groups],
:flavor_id => config[:flavor],
:key_name => Chef::Config[:knife][:aws_ssh_key_id],
:availability_zone => config[:availability_zone]
)
puts "#{h.color("Instance ID", :cyan)}: #{server.id}"
puts "#{h.color("Flavor", :cyan)}: #{server.flavor_id}"
puts "#{h.color("Image", :cyan)}: #{server.image_id}"
puts "#{h.color("Availability Zone", :cyan)}: #{server.availability_zone}"
puts "#{h.color("Security Groups", :cyan)}: #{server.groups.join(", ")}"
puts "#{h.color("SSH Key", :cyan)}: #{server.key_name}"
print "\n#{h.color("Waiting for server", :magenta)}"
server.wait_for { print "."; ready? }
puts("\n")
puts "#{h.color("Public DNS Name", :cyan)}: #{server.dns_name}"
puts "#{h.color("Public IP Address", :cyan)}: #{server.ip_address}"
puts "#{h.color("Private DNS Name", :cyan)}: #{server.private_dns_name}"
puts "#{h.color("Private IP Address", :cyan)}: #{server.private_ip_address}"
print "\n#{h.color("Waiting for sshd", :magenta)}"
print(".") until tcp_test_ssh(server.dns_name) { sleep @initial_sleep_delay ||= 10; puts("done") }
bootstrap_for_node(server).run
puts "\n"
puts "#{h.color("Instance ID", :cyan)}: #{server.id}"
puts "#{h.color("Flavor", :cyan)}: #{server.flavor_id}"
puts "#{h.color("Image", :cyan)}: #{server.image_id}"
puts "#{h.color("Availability Zone", :cyan)}: #{server.availability_zone}"
puts "#{h.color("Security Groups", :cyan)}: #{server.groups.join(", ")}"
puts "#{h.color("SSH Key", :cyan)}: #{server.key_name}"
puts "#{h.color("Public DNS Name", :cyan)}: #{server.dns_name}"
puts "#{h.color("Public IP Address", :cyan)}: #{server.ip_address}"
puts "#{h.color("Private DNS Name", :cyan)}: #{server.private_dns_name}"
puts "#{h.color("Private IP Address", :cyan)}: #{server.private_ip_address}"
puts "#{h.color("Run List", :cyan)}: #{@name_args.join(', ')}"
end