class Chef::Resource::ChefClientSystemdTimer

Public Instance Methods

chef_client_cmd() click to toggle source

The chef-client command to run in the systemd unit.

@return [String]

# File lib/chef/resource/chef_client_systemd_timer.rb, line 135
def chef_client_cmd
  cmd = new_resource.chef_binary_path.dup
  cmd << " #{new_resource.daemon_options.join(" ")}" unless new_resource.daemon_options.empty?
  cmd << " --chef-license accept" if new_resource.accept_chef_license
  cmd << " -c #{::File.join(new_resource.config_directory, "client.rb")}"
  cmd
end
service_content() click to toggle source

The service content to pass to the systemd_unit

@return [Hash]

# File lib/chef/resource/chef_client_systemd_timer.rb, line 165
def service_content
  unit = {
    "Unit" => {
      "Description" => new_resource.description,
      "After" => "network.target auditd.service",
    },
    "Service" => {
      "Type" => "oneshot",
      "ExecStart" => chef_client_cmd,
      "SuccessExitStatus" => [3, 213, 35, 37, 41],
    },
    "Install" => { "WantedBy" => "multi-user.target" },
  }

  unit["Service"]["ConditionACPower"] = "true" unless new_resource.run_on_battery
  unit["Service"]["CPUQuota"] = new_resource.cpu_quota if new_resource.cpu_quota
  unit["Service"]["Environment"] = new_resource.environment.collect { |k, v| "\"#{k}=#{v}\"" } unless new_resource.environment.empty?
  unit
end
timer_content() click to toggle source

The timer content to pass to the systemd_unit

@return [Hash]

# File lib/chef/resource/chef_client_systemd_timer.rb, line 148
def timer_content
  {
  "Unit" => { "Description" => new_resource.description },
  "Timer" => {
    "OnBootSec" => new_resource.delay_after_boot,
    "OnUnitActiveSec" => new_resource.interval,
    "RandomizedDelaySec" => new_resource.splay,
    },
  "Install" => { "WantedBy" => "timers.target" },
  }
end