summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-02-12 09:37:18 -0800
committerGitHub <noreply@github.com>2020-02-12 09:37:18 -0800
commitbc2a6afbc974130d66be6eae0ba22279595494e3 (patch)
tree1f4798f92aa0003081cbda7b2351b59350068647
parent3375e6260261214f4410196ad73adac9a71f191b (diff)
parent1984ff59e182877b6358dc34ed4927fdd26db00b (diff)
downloadchef-bc2a6afbc974130d66be6eae0ba22279595494e3.tar.gz
Merge pull request #9361 from MsysTechnologiesllc/Kapil/MSYS-1249_file_cache_path_and_file_backup_path_is_not_reflecting_in_client.rb
Allow setting file_cache_path and file_backup_path value in client.rb during bootstrap
-rw-r--r--lib/chef/knife/core/bootstrap_context.rb8
-rw-r--r--spec/unit/knife/core/bootstrap_context_spec.rb14
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb
index 2b5887a7cf..0fe115a7e0 100644
--- a/lib/chef/knife/core/bootstrap_context.rb
+++ b/lib/chef/knife/core/bootstrap_context.rb
@@ -169,6 +169,14 @@ class Chef
client_rb << "fips true\n"
end
+ unless @chef_config[:file_cache_path].nil?
+ client_rb << "file_cache_path \"#{@chef_config[:file_cache_path]}\"\n"
+ end
+
+ unless @chef_config[:file_backup_path].nil?
+ client_rb << "file_backup_path \"#{@chef_config[:file_backup_path]}\"\n"
+ end
+
client_rb
end
diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb
index 029dd90875..4c2ee015eb 100644
--- a/spec/unit/knife/core/bootstrap_context_spec.rb
+++ b/spec/unit/knife/core/bootstrap_context_spec.rb
@@ -86,6 +86,20 @@ describe Chef::Knife::Core::BootstrapContext do
end
end
+ describe "when file_cache_path is set" do
+ let(:chef_config) { { file_cache_path: "/home/opscode/cache" } }
+ it "sets file_cache_path in the generated config file" do
+ expect(bootstrap_context.config_content).to include("file_cache_path \"/home/opscode/cache\"")
+ end
+ end
+
+ describe "when file_backup_path is set" do
+ let(:chef_config) { { file_backup_path: "/home/opscode/backup" } }
+ it "sets file_backup_path in the generated config file" do
+ expect(bootstrap_context.config_content).to include("file_backup_path \"/home/opscode/backup\"")
+ end
+ end
+
describe "alternate chef-client path" do
let(:chef_config) { { chef_client_path: "/usr/local/bin/chef-client" } }
it "runs chef-client from another path when specified" do