diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-03-20 21:42:41 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-03-23 15:46:31 -0700 |
commit | 637e2fa0df72b0dfbe5ded96090c9dfc8a5f54dd (patch) | |
tree | ee28fc45768084950121fd6560e8a09014521bed | |
parent | 72b0f6509682b648a7c72acb8f4db208e4e8ef66 (diff) | |
download | chef-637e2fa0df72b0dfbe5ded96090c9dfc8a5f54dd.tar.gz |
Use the dist values
This is a bit odd and I could go either way with this. Should chef_client_cron setup cinc when on a cinc system?
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/dist.rb | 4 | ||||
-rw-r--r-- | lib/chef/resource/chef_client_cron.rb | 13 |
2 files changed, 11 insertions, 6 deletions
diff --git a/lib/chef/dist.rb b/lib/chef/dist.rb index f5f63103fa..9221591b9b 100644 --- a/lib/chef/dist.rb +++ b/lib/chef/dist.rb @@ -54,6 +54,10 @@ class Chef # The user's configuration directory USER_CONF_DIR = ChefConfig::Dist::USER_CONF_DIR.freeze + # The suffix for Chef's /etc/chef, /var/chef and C:\\Chef directories + # "cinc" => /etc/cinc, /var/cinc, C:\\cinc + DIR_SUFFIX = ChefConfig::Dist::DIR_SUFFIX.freeze + # The server's configuration directory SERVER_CONF_DIR = "/etc/chef-server".freeze end diff --git a/lib/chef/resource/chef_client_cron.rb b/lib/chef/resource/chef_client_cron.rb index 7a5608d916..ae05b8373a 100644 --- a/lib/chef/resource/chef_client_cron.rb +++ b/lib/chef/resource/chef_client_cron.rb @@ -15,6 +15,7 @@ # require_relative "../resource" +require_relative "../dist" class Chef class Resource @@ -23,7 +24,7 @@ class Chef provides :chef_client_cron - description "Use the chef_client_cron resource to setup the Chef Infra Client 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." introduced "16.0" property :user, String, default: "root" @@ -33,16 +34,16 @@ class Chef property :weekday, [String, Integer], default: "*" property :mailto, String - property :job_name, String, default: "chef-client" + property :job_name, String, default: Chef::Dist::CLIENT property :splay, [Integer, String], default: 300 property :env_vars, Hash - property :config_directory, String, default: "/etc/chef" - property :log_directory, String, default: lazy { platform?("mac_os_x") ? "/Library/Logs/Chef" : "/var/log/chef" } + property :config_directory, String, default: Chef::Dist::CONF_DIR + property :log_directory, String, default: lazy { platform?("mac_os_x") ? "/Library/Logs/#{Chef::Dist::DIR_SUFFIX.capitalize}" : "/var/log/#{Chef::Dist::DIR_SUFFIX}" } property :log_file_name, String, default: "client.log" property :append_log_file, [true, false], default: false - property :chef_binary_path, String, default: "/opt/chef/bin/chef-client" + property :chef_binary_path, String, default: "/opt/#{Chef::Dist::DIR_SUFFIX}/bin/#{Chef::Dist::CLIENT}" property :daemon_options, Array, default: [] action :add do @@ -77,7 +78,7 @@ class Chef cmd << "#{new_resource.env_vars} " if new_resource.env_vars cmd << "#{new_resource.chef_binary_path} #{new_resource.daemon_options.join(" ")}" cmd << " #{new_resource.append_log_file ? ">>" : ">"} #{::File.join(new_resource.log_directory, new_resource.log_file_name)} 2>&1" - cmd << ' || echo "Chef Infra Client execution failed"' if new_resource.mailto + cmd << " || echo \"#{Chef::Dist::PRODUCT} execution failed\"" if new_resource.mailto cmd end end |