Skip to content

Commit

Permalink
Merge pull request #12416 from Stromweld/patch-1
Browse files Browse the repository at this point in the history
chef_client_config: ensure config property directories exist
  • Loading branch information
tas50 committed Jan 14, 2022
2 parents bf91015 + a75cbdb commit 06185b3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
@@ -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}
Expand Down
25 changes: 12 additions & 13 deletions lib/chef/resource/chef_client_config.rb
Expand Up @@ -249,21 +249,20 @@ def string_to_symbol(prop_val)
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
Expand Down

0 comments on commit 06185b3

Please sign in to comment.