class Chef::Resource::ChefClientCron
Public Instance Methods
Source
# File lib/chef/resource/chef_client_cron.rb, line 195 def client_command cmd = "" cmd << "/bin/sleep #{splay_sleep_time(new_resource.splay)}; " cmd << "#{which("nice")} -n #{new_resource.nice} " if new_resource.nice cmd << "#{new_resource.chef_binary_path} " cmd << "#{new_resource.daemon_options.join(" ")} " unless new_resource.daemon_options.empty? cmd << "-c #{::File.join(new_resource.config_directory, "client.rb")} " cmd << "--chef-license accept " if new_resource.accept_chef_license cmd << log_command cmd << " || echo \"#{ChefUtils::Dist::Infra::PRODUCT} execution failed\"" if new_resource.mailto cmd end
The complete cron command to run
@return [String]
Source
# File lib/chef/resource/chef_client_cron.rb, line 228 def cron_resource_type linux? ? :cron_d : :cron end
The type of cron resource to run. Linux systems all support the /etc/cron.d directory and can use the cron_d resource, but Solaris / AIX / FreeBSD need to use the crontab via the legacy cron resource.
@return [Symbol]
Source
# File lib/chef/resource/chef_client_cron.rb, line 213 def log_command if new_resource.append_log_file ">> #{::File.join(new_resource.log_directory, new_resource.log_file_name)} 2>&1" else "> #{::File.join(new_resource.log_directory, new_resource.log_file_name)} 2>&1" end end
The portion of the overall cron job that handles logging based on the append_log_file property
@return [String]
Source
# File lib/chef/resource/chef_client_cron.rb, line 184 def splay_sleep_time(splay) seed = node["shard_seed"] || Digest::MD5.hexdigest(node.name).to_s.hex random = Random.new(seed.to_i) random.rand(splay) end
Generate a uniformly distributed unique number to sleep from 0 to the splay time
@param [Integer] splay The number of seconds to splay
@return [Integer]