summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerdar Sutay <serdar@opscode.com>2014-10-24 13:33:44 -0700
committerSerdar Sutay <serdar@opscode.com>2014-10-24 13:33:44 -0700
commitadf1995120d81e9083e7b0650ad9afcab444aa85 (patch)
treeb0fc3e24d2b08757d9addf1ae7491e57f1cf30c5
parent5d9ab649c4898bf4050ecb527e34a9071e4f10ab (diff)
parent8802793016eff0c543d69fafc807b81f425d689f (diff)
downloadchef-adf1995120d81e9083e7b0650ad9afcab444aa85.tar.gz
Merge pull request #2196 from ClogenyTechnologies/sid/fix-bootstrap-options-precedence
[knife-ec2]Command-line options do not take precedence over knife.rb configuration (#247)
-rw-r--r--lib/chef/knife/bootstrap.rb14
-rw-r--r--spec/unit/knife/bootstrap_spec.rb8
2 files changed, 10 insertions, 12 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index a992cf5779..f159c9105b 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -280,14 +280,16 @@ 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]
+
+ # command line arguments and config file values are now merged into config in Chef::Knife#merge_configs
+ ssh.config[:ssh_user] = config[: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]
+ ssh.config[:ssh_gateway] = config[:ssh_gateway]
+ ssh.config[:forward_agent] = config[:forward_agent]
+ ssh.config[:identity_file] = config[: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]
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..2599e44a56 100644
--- a/spec/unit/knife/bootstrap_spec.rb
+++ b/spec/unit/knife/bootstrap_spec.rb
@@ -418,12 +418,6 @@ describe Chef::Knife::Bootstrap do
context "from the knife config file" do
let(:knife_ssh) do
knife.name_args = ["config.example.com"]
- knife.config[:ssh_user] = nil
- knife.config[:ssh_port] = nil
- knife.config[:ssh_gateway] = nil
- knife.config[:forward_agent] = nil
- knife.config[:identity_file] = nil
- knife.config[:host_key_verify] = nil
Chef::Config[:knife][:ssh_user] = "curiosity"
Chef::Config[:knife][:ssh_port] = "2430"
Chef::Config[:knife][:forward_agent] = true
@@ -431,6 +425,8 @@ describe Chef::Knife::Bootstrap do
Chef::Config[:knife][:ssh_gateway] = "towel.blinkenlights.nl"
Chef::Config[:knife][:host_key_verify] = true
knife.stub(:render_template).and_return("")
+ knife.config = {}
+ knife.merge_configs
knife.knife_ssh
end