diff options
author | dheerajd-msys <dheeraj.dubey@msystechnologies.com> | 2020-08-14 17:00:13 +0530 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-09-02 13:58:02 -0700 |
commit | 147f7bf6e092e8485f184dd3796cef20c0092481 (patch) | |
tree | db49aba1e1a8507dbeb4827d9df321b05070e22c | |
parent | 570bae8fd68d5a31474fc6c159931bebe2be72b5 (diff) | |
download | chef-147f7bf6e092e8485f184dd3796cef20c0092481.tar.gz |
inserted rescue
Signed-off-by: dheerajd-msys <dheeraj.dubey@msystechnologies.com>
-rw-r--r-- | lib/chef/knife/ssh.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb index e1dbf8446a..d20052b736 100644 --- a/lib/chef/knife/ssh.rb +++ b/lib/chef/knife/ssh.rb @@ -362,7 +362,11 @@ class Chef subsession ||= session command = fixup_sudo(command) command.force_encoding("binary") if command.respond_to?(:force_encoding) - open_session(subsession, command) + begin + open_session(subsession, command) + rescue => e + open_session(subsession, command, true) + end end def open_session(subsession, command, pty = false) @@ -390,7 +394,6 @@ class Chef ch.on_request "exit-status" do |ichannel, data| exit_status = [exit_status, data.read_long].max - exit_status = open_session(subsession, command, true) if exit_status != 0 && stderr.include?("sudo: sorry, you must have a tty to run sudo") end end end |