summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivek Singh <vivek.singh@msystechnologies.com>2019-08-29 11:47:20 +0530
committerVivek Singh <vivek.singh@msystechnologies.com>2019-08-29 11:47:20 +0530
commitc111f1906a85fa098b0f6eb9b785ee0ca6fc9efa (patch)
treebca0a13b0f1144a03821820d4d5c5b951bea6f9c
parent1ea61ba8bb6a7f455fb535f2b3626fcfbc53932d (diff)
downloadchef-c111f1906a85fa098b0f6eb9b785ee0ca6fc9efa.tar.gz
Replace exception text check with reason symbol
Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
-rw-r--r--lib/chef/knife/bootstrap.rb2
-rw-r--r--spec/unit/knife/bootstrap_spec.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index 612e119760..efa1515858 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -673,7 +673,7 @@ class Chef
@connection = TrainConnector.new(host_descriptor, connection_protocol, conn_options)
connection.connect!
rescue Train::UserError => e
- if !conn_options.key?(:pty) && e.message =~ /Sudo requires a TTY/
+ if !conn_options.key?(:pty) && e.reason == :sudo_no_tty
ui.warn("#{e.message} - trying with pty request")
conn_options[:pty] = true # ensure we can talk to systems with requiretty set true in sshd config
retry
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb
index ac31e31a51..752fcff1e3 100644
--- a/spec/unit/knife/bootstrap_spec.rb
+++ b/spec/unit/knife/bootstrap_spec.rb
@@ -2001,7 +2001,7 @@ describe Chef::Knife::Bootstrap do
context "when sshd confgiured with requiretty" do
let(:pty_err_msg) { "Sudo requires a TTY. Please see the README on how to configure sudo to allow for non-interactive usage." }
- let(:expected_error) { Train::UserError.new(pty_err_msg) }
+ let(:expected_error) { Train::UserError.new(pty_err_msg, :sudo_no_tty) }
before do
allow(connection).to receive(:connect!).and_raise(expected_error)
end