summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-03-23 16:24:24 -0700
committerTim Smith <tsmith84@gmail.com>2020-03-23 16:32:28 -0700
commitb61653fcbe7ed9518da0d240e6c71b623281f10b (patch)
tree9580b8439dbc630675f3df844964b90d7125da3f
parent6f55214fd33490c1bce0c57e4b77591c095a1c9d (diff)
downloadchef-b61653fcbe7ed9518da0d240e6c71b623281f10b.tar.gz
Create the log directory if it's missing
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/chef_client_cron.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/chef/resource/chef_client_cron.rb b/lib/chef/resource/chef_client_cron.rb
index 6c60c9dc16..9d664b033a 100644
--- a/lib/chef/resource/chef_client_cron.rb
+++ b/lib/chef/resource/chef_client_cron.rb
@@ -25,7 +25,7 @@ class Chef
provides :chef_client_cron
- description "Use the chef_client_cron resource to setup the #{Chef::Dist::PRODUCT} to run as a cron job."
+ description "Use the chef_client_cron resource to setup the #{Chef::Dist::PRODUCT} to run as a cron job. This resource will also create the specified log directory if it doesn't already exist."
introduced "16.0"
examples <<~DOC
Setup #{Chef::Dist::PRODUCT} to run using the default 30 minute cadence
@@ -125,6 +125,15 @@ class Chef
description: "An array of options to pass to the #{Chef::Dist::CLIENT} command."
action :add do
+ # TODO: Replace this with a :create_if_missing action on directory when that exists
+ unless ::Dir.exist?(new_resource.log_directory)
+ directory new_resource.log_directory do
+ owner new_resource.user
+ mode "0640"
+ recursive true
+ end
+ end
+
cron_d new_resource.job_name do
minute new_resource.minute
hour new_resource.hour