class Chef::Resource::ChefClientScheduledTask
Public Instance Methods
client_cmd()
click to toggle source
Build command line to pass to cmd.exe
@return [String]
# File lib/chef/resource/chef_client_scheduled_task.rb, line 227 def client_cmd cmd = new_resource.chef_binary_path.dup cmd << " -L #{::File.join(new_resource.log_directory, new_resource.log_file_name)}" cmd << " -c #{::File.join(new_resource.config_directory, "client.rb")}" # Add custom options cmd << " #{new_resource.daemon_options.join(" ")}" if new_resource.daemon_options.any? cmd << " --chef-license accept" if new_resource.accept_chef_license cmd end
consistent_splay_command()
click to toggle source
The consistent splay sleep time when use_consistent_splay is true.
@return [NilClass,String] The prepended sleep command to run prior to executing the full command.
# File lib/chef/resource/chef_client_scheduled_task.rb, line 216 def consistent_splay_command return unless new_resource.use_consistent_splay "C:/windows/system32/windowspowershell/v1.0/powershell.exe Start-Sleep -s #{splay_sleep_time(new_resource.splay)} && " end
frequency_supports_frequency_modifier?()
click to toggle source
not all frequencies in the windows_task resource support frequency_modifier
@return [boolean]
# File lib/chef/resource/chef_client_scheduled_task.rb, line 252 def frequency_supports_frequency_modifier? # these are the only ones that don't !%w{once on_logon onstart on_idle}.include?(new_resource.frequency) end
frequency_supports_random_delay?()
click to toggle source
not all frequencies in the windows_task resource support random_delay
@return [boolean]
# File lib/chef/resource/chef_client_scheduled_task.rb, line 243 def frequency_supports_random_delay? %w{once minute hourly daily weekly monthly}.include?(new_resource.frequency) end
full_command()
click to toggle source
The full command to run in the scheduled task
@return [String]
# File lib/chef/resource/chef_client_scheduled_task.rb, line 191 def full_command # Fetch path of cmd.exe through environment variable comspec cmd_path = ENV["COMSPEC"] "#{cmd_path} /c \"#{consistent_splay_command}#{client_cmd}\"" end
splay_sleep_time(splay)
click to toggle source
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]
# File lib/chef/resource/chef_client_scheduled_task.rb, line 205 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