summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordheerajd-msys <dheeraj.dubey@msystechnologies.com>2020-08-14 17:00:13 +0530
committerdheerajd-msys <dheeraj.dubey@msystechnologies.com>2020-08-19 18:52:37 +0530
commitc88ea34bd538afba22358f8548ad1d7c01a44b5c (patch)
tree05d8cb047e22ed17df2d7bdc11a5dbe2e6ec2c49
parent3bcbf46825ad7d3856bc4aa28ff65184c5c82276 (diff)
downloadchef-c88ea34bd538afba22358f8548ad1d7c01a44b5c.tar.gz
inserted rescue
Signed-off-by: dheerajd-msys <dheeraj.dubey@msystechnologies.com>
-rw-r--r--lib/chef/knife/ssh.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/chef/knife/ssh.rb b/lib/chef/knife/ssh.rb
index f7df0f788f..a6428d9726 100644
--- a/lib/chef/knife/ssh.rb
+++ b/lib/chef/knife/ssh.rb
@@ -358,7 +358,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)
@@ -386,7 +390,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