diff options
author | Sarkis Varozian <svarozian@gmail.com> | 2017-11-11 08:43:09 -0800 |
---|---|---|
committer | Sarkis Varozian <svarozian@gmail.com> | 2017-11-11 08:51:59 -0800 |
commit | 8c222f3f58056626cb62b1fb4c38c605ea226b43 (patch) | |
tree | 9029ded83cae8e4210345aa27be2c17a05e12c22 | |
parent | 55d8f5c04eb2370560ee21609ec590659766743d (diff) | |
download | chef-8c222f3f58056626cb62b1fb4c38c605ea226b43.tar.gz |
refactor on_error option
Signed-off-by: Sarkis Varozian <svarozian@gmail.com>
-rw-r--r-- | lib/chef/knife/ssh.rb | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb index e47a27f0c3..71d3e287eb 100644 --- a/lib/chef/knife/ssh.rb +++ b/lib/chef/knife/ssh.rb @@ -122,7 +122,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", @@ -131,15 +131,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 @@ -335,7 +333,7 @@ class Chef command = fixup_sudo(command) command.force_encoding("binary") if command.respond_to?(:force_encoding) subsession.open_channel do |chan| - if config[:on_error] == :raise && exit_status != 0 + if config[:on_error] && exit_status != 0 chan.close() else chan.request_pty |