Permalink
Browse files

fixes needed to complete bootstrapping process

  • Loading branch information...
1 parent 2876917 commit f706094f07cb74e4063184cb9a22d2bfa113b7cb @pperezrubio committed Feb 10, 2012
Showing with 9 additions and 8 deletions.
  1. +9 −8 .chef/plugins/knife/hatch.rb
@@ -268,13 +268,14 @@ def run
print "\n#{ui.color("Waiting for sshd", :magenta)}"
ssh_address = server.dns_name
+ public_dns_name = server.dns_name
if ( config[:ip] || (config[:ensure_public_ip] and server.public_ip_address == server.private_ip_address) )
public_ip = set_public_ip(connection, server, config[:ip])
- ssh_address = public_ip
if public_ip.nil?
ui.error("Unable to assign a public IP to instance #{server.id}")
exit 1
end
+ public_dns_name = public_ip
ssh_address = public_ip
print "\n#{ui.color("\nServer got public IP #{public_ip}", :magenta)}"
end
@@ -296,8 +297,8 @@ def run
if vpc_mode?
puts "#{ui.color("Subnet ID", :cyan)}: #{server.subnet_id}"
else
- puts "#{ui.color("Public DNS Name", :cyan)}: #{server.dns_name}"
- puts "#{ui.color("Public IP Address", :cyan)}: #{server.public_ip_address}"
+ puts "#{ui.color("Public DNS Name", :cyan)}: #{public_dns_name}"
+ puts "#{ui.color("Public IP Address", :cyan)}: #{ssh_address}"
puts "#{ui.color("Private DNS Name", :cyan)}: #{server.private_dns_name}"
end
puts "#{ui.color("SSH Key", :cyan)}: #{server.key_name}"
@@ -375,7 +376,7 @@ def bootstrap_for_node(server, ssh_address)
bootstrap.run
- Net::SSH.start(server.public_ip_address, config[:ssh_user], :keys => [config[:identity_file]]) do |ssh|
+ Net::SSH.start(ssh_address, config[:ssh_user], :keys => [config[:identity_file]]) do |ssh|
puts "#{ui.color("Creating admin user", :cyan)}"
ssh.exec! "cd /tmp/chef-hatch && sudo rake hatch:init['hatch']"
@@ -391,7 +392,7 @@ def bootstrap_for_node(server, ssh_address)
# Create knife.rb
puts "#{ui.color("Creating knife.rb", :cyan)}"
- setup_knife_config(server)
+ setup_knife_config(server, ssh_address)
puts "#{ui.color("Uploading all cookbooks", :cyan)}"
`knife cookbook upload --all`
@@ -425,7 +426,7 @@ def bootstrap_for_node(server, ssh_address)
end
puts "#{ui.color("Finishing hatching and restarting chef-client", :cyan)}"
- Net::SSH.start(server.public_ip_address, config[:ssh_user], :keys => [config[:identity_file]]) do |ssh|
+ Net::SSH.start(ssh_address, config[:ssh_user], :keys => [config[:identity_file]]) do |ssh|
ssh.exec! "cd /tmp/chef-hatch && sudo rake hatch:finish['#{bootstrap.config[:chef_node_name]}','#{config[:run_list].join(' ')}','#{config[:environment]}']"
ssh.exec! "sudo /etc/init.d/chef-client restart"
end
@@ -446,7 +447,7 @@ def vpc_mode?
!!config[:subnet_id]
end
- def setup_knife_config(server)
+ def setup_knife_config(server, ssh_address)
cwd = File.expand_path('./')
conf = <<-END_CONF
log_level :info
@@ -455,7 +456,7 @@ def setup_knife_config(server)
client_key '#{cwd}/.chef/hatch.pem'
validation_client_name 'chef-validator'
validation_key '#{cwd}/.chef/validation.pem'
- chef_server_url 'http://#{server.public_ip_address}:4000'
+ chef_server_url 'http://#{ssh_address}:4000'
cache_type 'BasicFile'
cache_options( :path => '#{cwd}/.chef/checksums' )
cookbook_path [ '#{cwd}/cookbooks' ]

0 comments on commit f706094

Please sign in to comment.