diff options
author | siddheshwar-more <siddheshwar.more@clogeny.com> | 2014-10-09 21:45:16 +0530 |
---|---|---|
committer | siddheshwar-more <siddheshwar.more@clogeny.com> | 2014-10-09 21:45:16 +0530 |
commit | 19cd53bcf0dad14c8def6aaf719f548b86d46164 (patch) | |
tree | e3c93cdaa720182f5f5950011662fd3931529505 | |
parent | d75c5b69de9ec183a0ba1c90c6dc5e3c58799301 (diff) | |
download | chef-19cd53bcf0dad14c8def6aaf719f548b86d46164.tar.gz |
Fixed issue related to precedence of knife config options
-rw-r--r-- | lib/chef/knife/bootstrap.rb | 12 | ||||
-rw-r--r-- | spec/unit/knife/bootstrap_spec.rb | 30 |
2 files changed, 36 insertions, 6 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb index a992cf5779..7552156ba5 100644 --- a/lib/chef/knife/bootstrap.rb +++ b/lib/chef/knife/bootstrap.rb @@ -280,14 +280,14 @@ class Chef ssh = Chef::Knife::Ssh.new ssh.ui = ui ssh.name_args = [ server_name, ssh_command ] - ssh.config[:ssh_user] = Chef::Config[:knife][:ssh_user] || config[:ssh_user] + ssh.config[:ssh_user] = config[:ssh_user] || Chef::Config[:knife][:ssh_user] ssh.config[:ssh_password] = config[:ssh_password] - ssh.config[:ssh_port] = Chef::Config[:knife][:ssh_port] || config[:ssh_port] - ssh.config[:ssh_gateway] = Chef::Config[:knife][:ssh_gateway] || config[:ssh_gateway] - ssh.config[:forward_agent] = Chef::Config[:knife][:forward_agent] || config[:forward_agent] - ssh.config[:identity_file] = Chef::Config[:knife][:identity_file] || config[:identity_file] + ssh.config[:ssh_port] = config[:ssh_port] || Chef::Config[:knife][:ssh_port] + ssh.config[:ssh_gateway] = config[:ssh_gateway] || Chef::Config[:knife][:ssh_gateway] + ssh.config[:forward_agent] = config[:forward_agent] || Chef::Config[:knife][:forward_agent] + ssh.config[:identity_file] = config[:identity_file] || Chef::Config[:knife][:identity_file] ssh.config[:manual] = true - ssh.config[:host_key_verify] = Chef::Config[:knife][:host_key_verify] || config[:host_key_verify] + ssh.config[:host_key_verify] = config[:host_key_verify] || Chef::Config[:knife][:host_key_verify] ssh.config[:on_error] = :raise ssh end diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb index 70cdd20f35..0036a2e40d 100644 --- a/spec/unit/knife/bootstrap_spec.rb +++ b/spec/unit/knife/bootstrap_spec.rb @@ -479,6 +479,36 @@ describe Chef::Knife::Bootstrap do knife_ssh_with_password_auth.config[:identity_file].should be_nil end end + + context "config precedence" do + let(:knife_ssh) do + knife.name_args = ["config.example.com"] + + knife.config[:ssh_port] = "cli_ssh_port" + knife.config[:ssh_gateway] = "cli_ssh_gateway" + knife.config[:forward_agent] = true + knife.config[:identity_file] = "cli_identity_file" + knife.config[:host_key_verify] = true + Chef::Config[:knife][:ssh_user] = "curiosity" + knife.config[:ssh_user] = "cli_ssh_user" + Chef::Config[:knife][:ssh_port] = "2430" + Chef::Config[:knife][:forward_agent] = false + Chef::Config[:knife][:identity_file] = "~/.ssh/you.rsa" + Chef::Config[:knife][:ssh_gateway] = "towel.blinkenlights.nl" + Chef::Config[:knife][:host_key_verify] = false + knife.stub(:render_template).and_return("") + knife.knife_ssh + end + + it "CLI params should take precedence over knife.rb" do + knife_ssh.config[:ssh_user].should == 'cli_ssh_user' + knife_ssh.config[:identity_file].should == 'cli_identity_file' + knife_ssh.config[:ssh_gateway].should == 'cli_ssh_gateway' + knife_ssh.config[:ssh_port].should == 'cli_ssh_port' + knife_ssh.config[:forward_agent].should be_true + knife_ssh.config[:host_key_verify].should be_true + end + end end it "verifies that a server to bootstrap was given as a command line arg" do |