diff options
author | Thom May <thom@may.lt> | 2018-01-29 18:49:31 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-29 18:49:31 +0000 |
commit | 213477f815764d80149bb14681ace479c5249e05 (patch) | |
tree | 892c2e218aab9610675008556ee13043da6e63f4 | |
parent | 2de590065c1cd42969d3c41ae3c20da069236688 (diff) | |
parent | 6b195b05f82e4bb52187b95533b460f33ecfc5d7 (diff) | |
download | chef-213477f815764d80149bb14681ace479c5249e05.tar.gz |
Merge pull request #6582 from sarkis/6581-fix-knife-ssh-on-error-behavior
use a stricter comparison so knife ssh only fails if --exit-on-error
-rw-r--r-- | lib/chef/knife/bootstrap.rb | 2 | ||||
-rw-r--r-- | lib/chef/knife/ssh.rb | 12 |
2 files changed, 6 insertions, 8 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb index f9dca7896a..9decacce13 100644 --- a/lib/chef/knife/bootstrap.rb +++ b/lib/chef/knife/bootstrap.rb @@ -448,7 +448,7 @@ class Chef ssh.config[:ssh_identity_file] = config[:ssh_identity_file] || config[:identity_file] ssh.config[:manual] = true ssh.config[:host_key_verify] = config[:host_key_verify] - ssh.config[:on_error] = :raise + ssh.config[:on_error] = true ssh end diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb index 6d79cd10fd..8e13425f82 100644 --- a/lib/chef/knife/ssh.rb +++ b/lib/chef/knife/ssh.rb @@ -121,7 +121,7 @@ class Chef :long => "--exit-on-error", :description => "Immediately exit if an error is encountered", :boolean => true, - :proc => Proc.new { :raise } + :default => false option :tmux_split, :long => "--tmux-split", @@ -130,15 +130,13 @@ class Chef :default => false def session - config[:on_error] ||= :skip ssh_error_handler = Proc.new do |server| - case config[:on_error] - when :skip - ui.warn "Failed to connect to #{server.host} -- #{$!.class.name}: #{$!.message}" - $!.backtrace.each { |l| Chef::Log.debug(l) } - when :raise + if config[:on_error] #Net::SSH::Multi magic to force exception to be re-raised. throw :go, :raise + else + ui.warn "Failed to connect to #{server.host} -- #{$!.class.name}: #{$!.message}" + $!.backtrace.each { |l| Chef::Log.debug(l) } end end |