diff options
-rw-r--r-- | lib/chef/knife/bootstrap.rb | 1 | ||||
-rw-r--r-- | lib/chef/knife/ssh.rb | 11 | ||||
-rw-r--r-- | lib/chef/provider.rb | 1 | ||||
-rw-r--r-- | lib/chef/provider/service.rb | 2 | ||||
-rw-r--r-- | spec/unit/knife/bootstrap_spec.rb | 10 | ||||
-rw-r--r-- | spec/unit/knife/ssh_spec.rb | 17 | ||||
-rw-r--r-- | spec/unit/provider/route_spec.rb | 1 |
7 files changed, 36 insertions, 7 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb index a8e9201c26..a4c117e28f 100644 --- a/lib/chef/knife/bootstrap.rb +++ b/lib/chef/knife/bootstrap.rb @@ -51,7 +51,6 @@ class Chef :short => "-p PORT", :long => "--ssh-port PORT", :description => "The ssh port", - :default => "22", :proc => Proc.new { |key| Chef::Config[:knife][:ssh_port] = key } option :ssh_gateway, diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb index a1b37723a6..ed3c559d05 100644 --- a/lib/chef/knife/ssh.rb +++ b/lib/chef/knife/ssh.rb @@ -72,7 +72,6 @@ class Chef :short => "-p PORT", :long => "--ssh-port PORT", :description => "The ssh port", - :default => "22", :proc => Proc.new { |key| Chef::Config[:knife][:ssh_port] = key } option :ssh_gateway, @@ -166,13 +165,17 @@ class Chef list.each do |item| Chef::Log.debug("Adding #{item}") - - hostspec = config[:ssh_user] ? "#{config[:ssh_user]}@#{item}" : item session_opts = {} + + ssh_config = Net::SSH.configuration_for(item) + + # Chef::Config[:knife][:ssh_user] is parsed in #configure_user and written to config[:ssh_user] + user = config[:ssh_user] || ssh_config[:user] + hostspec = user ? "#{user}@#{item}" : item session_opts[:keys] = File.expand_path(config[:identity_file]) if config[:identity_file] session_opts[:keys_only] = true if config[:identity_file] session_opts[:password] = config[:ssh_password] if config[:ssh_password] - session_opts[:port] = Chef::Config[:knife][:ssh_port] || config[:ssh_port] + session_opts[:port] = config[:ssh_port] || Chef::Config[:knife][:ssh_port] || ssh_config[:port] session_opts[:logger] = Chef::Log.logger if Chef::Log.level == :debug if !config[:host_key_verify] diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb index 158b77a647..fef75deee5 100644 --- a/lib/chef/provider.rb +++ b/lib/chef/provider.rb @@ -122,6 +122,7 @@ class Chef else send("action_#{@action}") end + set_updated_status cleanup_after_converge diff --git a/lib/chef/provider/service.rb b/lib/chef/provider/service.rb index a674f38145..8d76927676 100644 --- a/lib/chef/provider/service.rb +++ b/lib/chef/provider/service.rb @@ -121,7 +121,7 @@ class Chef def action_reload if @current_resource.running - converge_by("disable service #{@new_resource}") do + converge_by("reload service #{@new_resource}") do reload_service Chef::Log.info("#{@new_resource} reloaded") end diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb index b2247bb5a4..76261d96ab 100644 --- a/spec/unit/knife/bootstrap_spec.rb +++ b/spec/unit/knife/bootstrap_spec.rb @@ -22,6 +22,16 @@ Chef::Knife::Bootstrap.load_deps require 'net/ssh' describe Chef::Knife::Bootstrap do + before(:all) do + @original_config = Chef::Config.hash_dup + @original_knife_config = Chef::Config[:knife].dup + end + + after(:all) do + Chef::Config.configuration = @original_config + Chef::Config[:knife] = @original_knife_config + end + before(:each) do Chef::Log.logger = Logger.new(StringIO.new) @knife = Chef::Knife::Bootstrap.new diff --git a/spec/unit/knife/ssh_spec.rb b/spec/unit/knife/ssh_spec.rb index 6e90a87f01..1652193c0b 100644 --- a/spec/unit/knife/ssh_spec.rb +++ b/spec/unit/knife/ssh_spec.rb @@ -178,5 +178,22 @@ describe Chef::Knife::Ssh do end end + describe "#session_from_list" do + before :each do + @knife.instance_variable_set(:@longest, 0) + ssh_config = {:timeout => 50, :user => "locutus", :port => 23 } + Net::SSH.stub!(:configuration_for).with('the.b.org').and_return(ssh_config) + end + + it "uses the port from an ssh config file" do + @knife.session_from_list(['the.b.org']) + @knife.session.servers[0].port.should == 23 + end + + it "uses the user from an ssh config file" do + @knife.session_from_list(['the.b.org']) + @knife.session.servers[0].user.should == "locutus" + end + end end diff --git a/spec/unit/provider/route_spec.rb b/spec/unit/provider/route_spec.rb index bcbed10026..8d486d55e8 100644 --- a/spec/unit/provider/route_spec.rb +++ b/spec/unit/provider/route_spec.rb @@ -204,7 +204,6 @@ describe Chef::Provider::Route do File.should_receive(:new).with("/etc/sysconfig/network-scripts/route-eth0", "w").and_return(route_file) #Chef::Log.should_receive(:debug).with("route[10.0.0.10] writing route.eth0\n10.0.0.10 via 10.0.0.9\n") @run_context.resource_collection << @new_resource - @provider.generate_config end end |