Puppet Class: puppet::agent::service::systemd

Defined in:
manifests/agent/service/systemd.pp

Overview

Set up running the agent via a systemd timer

Parameters:

  • enabled (Boolean) (defaults to: false)
  • hour (Optional[Integer[0,23]]) (defaults to: undef)
  • minute (Variant[Integer[0,59], Array[Integer[0,59]], Undef]) (defaults to: undef)


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'manifests/agent/service/systemd.pp', line 3

class puppet::agent::service::systemd (
  Boolean                 $enabled                             = false,
  Optional[Integer[0,23]] $hour                                = undef,
  Variant[Integer[0,59], Array[Integer[0,59]], Undef] $minute  = undef,
) {
  unless $puppet::runmode == 'unmanaged' or 'systemd.timer' in $puppet::unavailable_runmodes {
    # Use the same times as for cron
    $times = extlib::ip_to_cron($puppet::runinterval)

    # But only if they are not explicitly specified
    $_hour = pick($hour, $times[0])
    $_minute = pick($minute, $times[1])

    $command = pick($puppet::systemd_cmd, "${puppet::puppet_cmd} agent --config ${puppet::dir}/puppet.conf --onetime --no-daemonize --detailed-exitcode --no-usecacheonfailure")
    $randomizeddelaysec = $puppet::systemd_randomizeddelaysec

    systemd::timer { "${puppet::systemd_unit_name}.timer":
      ensure          => bool2str($enabled, 'present', 'absent'),
      active          => $enabled,
      enable          => $enabled,
      timer_content   => template('puppet/agent/systemd.puppet-run.timer.erb'),
      service_content => template('puppet/agent/systemd.puppet-run.service.erb'),
    }
  }
}