summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc A. Paradise <marc.paradise@gmail.com>2019-05-16 14:22:50 -0400
committerMarc A. Paradise <marc.paradise@gmail.com>2019-05-16 14:27:45 -0400
commita5e4af782cb3575d660008c00b6fa873fb3d6c34 (patch)
treed49057ba9aa6cc325c60c6fed678c3f70e3d80e0
parent53a541c3016a6257d7aea47739ac5689f73045cc (diff)
downloadchef-a5e4af782cb3575d660008c00b6fa873fb3d6c34.tar.gz
Enable pty for bootstrap sshbootstrap-uses-pty
This will allow bootstrap to work with systems that have `requiretty` configured, and is consistent with the behavior of Chef 14 bootstrap Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
-rw-r--r--lib/chef/knife/bootstrap.rb1
-rw-r--r--spec/unit/knife/bootstrap_spec.rb37
2 files changed, 24 insertions, 14 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index 1e5580a61d..66d73a3372 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -865,6 +865,7 @@ class Chef
def ssh_opts
opts = {}
return opts if winrm?
+ opts[:pty] = true # ensure we can talk to systems with requiretty set true in sshd config
opts[:non_interactive] = true # Prevent password prompts from underlying net/ssh
opts[:forward_agent] = (config_value(:ssh_forward_agent) === true)
opts[:connection_timeout] = session_timeout
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb
index 5118442327..8467b6dc70 100644
--- a/spec/unit/knife/bootstrap_spec.rb
+++ b/spec/unit/knife/bootstrap_spec.rb
@@ -1015,6 +1015,7 @@ describe Chef::Knife::Bootstrap do
verify_host_key: false,
port: 9999,
non_interactive: true,
+ pty: true,
}
end
@@ -1069,6 +1070,7 @@ describe Chef::Knife::Bootstrap do
verify_host_key: false, # Config
port: 12, # cli
non_interactive: true,
+ pty: true,
}
end
@@ -1120,6 +1122,7 @@ describe Chef::Knife::Bootstrap do
sudo_password: "blah",
verify_host_key: true,
non_interactive: true,
+ pty: true,
}
end
it "generates a config hash using the CLI options and pulling nothing from Chef::Config" do
@@ -1143,6 +1146,7 @@ describe Chef::Knife::Bootstrap do
sudo: false,
verify_host_key: "always",
non_interactive: true,
+ pty: true,
connection_timeout: 60,
}
end
@@ -1491,33 +1495,38 @@ describe Chef::Knife::Bootstrap do
context "for ssh" do
let(:connection_protocol) { "ssh" }
+ let(:default_opts) do
+ {
+ non_interactive: true,
+ pty: true,
+ forward_agent: false,
+ connection_timeout: 60,
+ }
+ end
+
+ context "by default" do
+ it "returns a configuration hash with appropriate defaults" do
+ expect(knife.ssh_opts).to eq default_opts
+ end
+ end
+
context "when ssh_forward_agent has a value" do
before do
knife.config[:ssh_forward_agent] = true
end
- it "returns a configuration hash with forward_agent set to true. non-interactive is always true" do
- expect(knife.ssh_opts).to eq({ forward_agent: true, non_interactive: true, connection_timeout: 60 })
- end
- end
- context "when ssh_forward_agent is not set" do
- it "returns a configuration hash with forward_agent set to false. non-interactive is always true" do
- expect(knife.ssh_opts).to eq({ forward_agent: false, non_interactive: true, connection_timeout: 60 })
+ it "returns a default configuration hash with forward_agent set to true" do
+ expect(knife.ssh_opts).to eq(default_opts.merge(forward_agent: true))
end
end
context "when session_timeout has a value" do
before do
knife.config[:session_timeout] = 120
end
- it "returns a configuration hash with connection_timeout value." do
- expect(knife.ssh_opts).to eq({ forward_agent: false, non_interactive: true, connection_timeout: 120 })
+ it "returns a default configuration hash with updated timeout value." do
+ expect(knife.ssh_opts).to eq(default_opts.merge(connection_timeout: 120))
end
end
- context "when session_timeout is not set" do
- it "returns a configuration hash with connection_timeout default value." do
- expect(knife.ssh_opts).to eq({ forward_agent: false, non_interactive: true, connection_timeout: 60 })
- end
- end
end
context "for winrm" do