diff options
author | Thom May <thom@chef.io> | 2016-06-24 15:27:24 +0100 |
---|---|---|
committer | Thom May <thom@chef.io> | 2016-06-24 15:28:39 +0100 |
commit | f06d2eb5c3100fb567a39148a2c414f653c5d20e (patch) | |
tree | b8b742f8d2ae9c62be5668a6e02f86558b72757a | |
parent | 20774deff25b952ff24d6e6d100007713dcbf005 (diff) | |
download | chef-tm/correct_repo_path.tar.gz |
Ensure that chef-solo uses the expected repo dirtm/correct_repo_path
Solo has always defaulted to `/var/chef` but local-mode uses the user's
home directory, so we need to ensure that we set the correct path before
entering local-mode.
Fixes: #5051
Signed-off-by: Thom May <thom@may.lt>
-rw-r--r-- | lib/chef/application/solo.rb | 7 | ||||
-rw-r--r-- | spec/unit/application/solo_spec.rb | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb index ecac3f4d4e..d2516926c4 100644 --- a/lib/chef/application/solo.rb +++ b/lib/chef/application/solo.rb @@ -241,6 +241,13 @@ class Chef::Application::Solo < Chef::Application ARGV[dash_r] = "--recipe-url" end + # For back compat reasons, we need to ensure that we try and use the cache_path as a repo first + Chef::Log.debug "Current chef_repo_path is #{Chef::Config.chef_repo_path}" + + if !Chef::Config.has_key?(:cookbook_path) && !Chef::Config.has_key?(:chef_repo_path) + Chef::Config.chef_repo_path = Chef::Config.find_chef_repo_path(Chef::Config[:cache_path]) + end + Chef::Config[:local_mode] = true else configure_legacy_mode! diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb index bb29261f5a..b1931414cc 100644 --- a/spec/unit/application/solo_spec.rb +++ b/spec/unit/application/solo_spec.rb @@ -212,6 +212,13 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config end end + it "sets the repo path" do + expect(Chef::Config).to receive(:find_chef_repo_path).and_return("/var/chef") + app.reconfigure + expect(Chef::Config.has_key?(:chef_repo_path)).to be_truthy + expect(Chef::Config[:chef_repo_path]).to eq ("/var/chef") + end + it "runs chef-client in local mode" do allow(app).to receive(:setup_application).and_return(true) allow(app).to receive(:run_application).and_return(true) |