diff options
author | Tim Smith <tsmith@chef.io> | 2019-05-16 11:56:48 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-16 11:56:48 -0700 |
commit | 39bf910d0ce92f754766efb6e286f29f08805244 (patch) | |
tree | d49057ba9aa6cc325c60c6fed678c3f70e3d80e0 | |
parent | 53a541c3016a6257d7aea47739ac5689f73045cc (diff) | |
parent | a5e4af782cb3575d660008c00b6fa873fb3d6c34 (diff) | |
download | chef-39bf910d0ce92f754766efb6e286f29f08805244.tar.gz |
Merge pull request #8560 from chef/bootstrap-uses-pty
Enable pty for bootstrap ssh
-rw-r--r-- | lib/chef/knife/bootstrap.rb | 1 | ||||
-rw-r--r-- | spec/unit/knife/bootstrap_spec.rb | 37 |
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 |