summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2022-01-13 17:38:40 -0800
committerGitHub <noreply@github.com>2022-01-13 17:38:40 -0800
commit06185b342784a40891be8850fcad97221e290f70 (patch)
treeef5f666a859094afa746332ca5a492826d7aa9ec
parentbf910156881097df5e02d9f0266347b54224367d (diff)
parenta75cbdb45c5fe2a7a6a844f980e63f33edd22c23 (diff)
downloadchef-06185b342784a40891be8850fcad97221e290f70.tar.gz
Merge pull request #12416 from Stromweld/patch-1
chef_client_config: ensure config property directories exist
-rw-r--r--kitchen-tests/cookbooks/end_to_end/recipes/_chef_client_config.rb1
-rw-r--r--lib/chef/resource/chef_client_config.rb25
2 files changed, 13 insertions, 13 deletions
diff --git a/kitchen-tests/cookbooks/end_to_end/recipes/_chef_client_config.rb b/kitchen-tests/cookbooks/end_to_end/recipes/_chef_client_config.rb
index c2a6e4254b..31dac49fc6 100644
--- a/kitchen-tests/cookbooks/end_to_end/recipes/_chef_client_config.rb
+++ b/kitchen-tests/cookbooks/end_to_end/recipes/_chef_client_config.rb
@@ -1,5 +1,6 @@
chef_client_config "Create chef-client's client.rb" do
chef_server_url "https://localhost"
+ log_location windows? ? "C:\\chef\\log_test\\client.log" : "/var/log/chef/log_test/client.log"
chef_license "accept"
ohai_optional_plugins %i{Passwd Lspci Sysctl}
ohai_disabled_plugins %i{Sessions Interrupts}
diff --git a/lib/chef/resource/chef_client_config.rb b/lib/chef/resource/chef_client_config.rb
index df97d7cc2f..e02010a147 100644
--- a/lib/chef/resource/chef_client_config.rb
+++ b/lib/chef/resource/chef_client_config.rb
@@ -249,21 +249,20 @@ class Chef
description: "The data collector token to interact with the data collector server URL (Automate). Note: If possible, use Chef Infra Server to do all data collection reporting, as this removes the need to distribute tokens to individual nodes.",
introduced: "17.8"
- action :create, description: "Create a client.rb config file for configuring #{ChefUtils::Dist::Infra::PRODUCT}." do
- unless ::Dir.exist?(new_resource.config_directory)
- directory new_resource.config_directory do
+ action :create, description: "Create a client.rb config file and folders for configuring #{ChefUtils::Dist::Infra::PRODUCT}." do
+ [
+ new_resource.config_directory,
+ (::File.dirname(new_resource.log_location) unless new_resource.log_location.nil?),
+ new_resource.file_backup_path,
+ new_resource.file_cache_path,
+ ::File.join(new_resource.config_directory, "client.d"),
+ (::File.dirname(new_resource.pid_file) unless new_resource.pid_file.nil?),
+ ].compact.each do |dir_path|
+
+ directory dir_path do
user new_resource.user unless new_resource.user.nil?
group new_resource.group unless new_resource.group.nil?
- mode "0750"
- recursive true
- end
- end
-
- unless ::Dir.exist?(::File.join(new_resource.config_directory, "client.d"))
- directory ::File.join(new_resource.config_directory, "client.d") do
- user new_resource.user unless new_resource.user.nil?
- group new_resource.group unless new_resource.group.nil?
- mode "0750"
+ mode dir_path == ::File.dirname(new_resource.log_location) ? "0755" : "0750"
recursive true
end
end