lib/chef/knife/server_bootstrap_standalone.rb in knife-server-0.3.3 vs lib/chef/knife/server_bootstrap_standalone.rb in knife-server-1.0.0

- old
+ new

@@ -20,31 +20,30 @@ class Chef class Knife class ServerBootstrapStandalone < Knife + banner "knife server bootstrap standalone (options)" + include Knife::ServerBootstrapBase deps do require 'knife/server/ssh' require 'knife/server/credentials' require 'chef/knife/bootstrap' Chef::Knife::Bootstrap.load_deps + + current_options = self.options + self.options = Chef::Knife::Bootstrap.options.dup + self.options.merge!(current_options) end - banner "knife server bootstrap standalone (options)" - option :host, :short => "-H FQDN_OR_IP", :long => "--host FQDN_OR_IP", :description => "Hostname or IP address of host to bootstrap" - option :ssh_password, - :short => "-P PASSWORD", - :long => "--ssh-password PASSWORD", - :description => "The ssh password" - def run validate! check_ssh_connection standalone_bootstrap.run fetch_validation_key @@ -55,14 +54,15 @@ def standalone_bootstrap ENV['WEBUI_PASSWORD'] = config[:webui_password] ENV['AMQP_PASSWORD'] = config[:amqp_password] bootstrap = Chef::Knife::Bootstrap.new bootstrap.name_args = [ config[:host] ] - [ :chef_node_name, :ssh_user, :ssh_password, :ssh_port, :identity_file - ].each { |attr| bootstrap.config[attr] = config[attr] } + Chef::Knife::Bootstrap.options.keys.each do |attr| + bootstrap.config[attr] = config_val(attr) + end bootstrap.config[:distro] = bootstrap_distro - bootstrap.config[:use_sudo] = true unless config[:ssh_user] == "root" + bootstrap.config[:use_sudo] = true unless config_val(:ssh_user) == "root" bootstrap end private @@ -78,24 +78,30 @@ end def check_ssh_connection ssh_connection.exec! "hostname -f" rescue Net::SSH::AuthenticationFailed - ui.warn("Failed to authenticate #{config[:ssh_user]} - " + + ui.warn("Failed to authenticate #{config_val(:ssh_user)} - " + "trying password auth") config[:ssh_password] = ui.ask( - "Enter password for #{config[:ssh_user]}@#{config[:host]}: " + "Enter password for #{config_val(:ssh_user)}@#{config_val(:host)}: " ) { |q| q.echo = false } end def ssh_connection - ::Knife::Server::SSH.new( - :host => config[:host], - :user => config[:ssh_user], - :password => config[:ssh_password], - :port => config[:ssh_port], - :keys => [config[:identity_file]].compact - ) + opts = { + :host => config_val(:host), + :user => config_val(:ssh_user), + :password => config_val(:ssh_password), + :port => config_val(:ssh_port), + :keys => [config_val(:identity_file)].compact + } + if config_val(:host_key_verify) == false + opts[:user_known_hosts_file] = "/dev/null" + opts[:paranoid] = false + end + + ::Knife::Server::SSH.new(opts) end end end end