summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2018-02-22 08:40:57 +0000
committerGitHub <noreply@github.com>2018-02-22 08:40:57 +0000
commit6ff07ab5b10f56bebfa44a7a1e4dd07d9acb1ed3 (patch)
tree719be92934b863d30ab248f21f16ecdbf9cd1383
parent8dfedb088cfb9859c0ffdb6783b9c72d4d5dad99 (diff)
parent9c354415e6fe942b48d0b23eaff8b67c664397e0 (diff)
downloadchef-6ff07ab5b10f56bebfa44a7a1e4dd07d9acb1ed3.tar.gz
Merge pull request #6894 from chef/knife_ssh_exit
use a stricter comparison so knife ssh only fails if --exit-on-error
-rw-r--r--lib/chef/knife/bootstrap.rb2
-rw-r--r--lib/chef/knife/ssh.rb12
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 b6abd67719..a596bfaabb 100644
--- a/lib/chef/knife/ssh.rb
+++ b/lib/chef/knife/ssh.rb
@@ -125,7 +125,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",
@@ -134,15 +134,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