Defined Type: systemd::timer

Defined in:
manifests/timer.pp

Summary

Create a timer and optionally a service unit to execute with the timer unit

Overview

Parameters:

  • name (Pattern['^.+\.timer$])

    The target of the timer unit to create

  • path (Stdlib::Absolutepath) (defaults to: '/etc/systemd/system')

    The main systemd configuration path

  • timer_content (Optional[String[1]]) (defaults to: undef)

    The full content of the timer unit file

    • Mutually exclusive with “$timer_source“

  • timer_source (Optional[String[1]]) (defaults to: undef)

    The “File“ resource compatible “source“

    • Mutually exclusive with “$timer_content“

  • service_content (Optional[String[1]]) (defaults to: undef)

    The full content of the service unit file

    • Mutually exclusive with “$service_source“

  • service_source (Optional[String[1]]) (defaults to: undef)

    The “File“ resource compatible “source“

    • Mutually exclusive with “$service_content“

  • owner (String[1]) (defaults to: 'root')

    The owner to set on the dropin file

  • group (String[1]) (defaults to: 'root')

    The group to set on the dropin file

  • mode (Stdlib::Filemode) (defaults to: '0444')

    The mode to set on the dropin file

  • show_diff (Boolean) (defaults to: true)

    Whether to show the diff when updating dropin file

  • service_unit (Optional[Systemd::Unit]) (defaults to: undef)

    If set then the service_unit will have this name. If not set the service unit has the same name as the timer unit with s/.timer/.service/

  • active (Optional[Boolean]) (defaults to: undef)

    If set to true or false the timer service will be maintained. If true the timer service will be running and enabled, if false it will explictly stopped and disabled.

  • enable (Optional[Variant[Boolean, Enum['mask']]]) (defaults to: undef)

    If set, will manage the state of the unit.

  • ensure (Enum['present', 'absent', 'file']) (defaults to: 'present')

    Defines the desired state of the timer

See Also:



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'manifests/timer.pp', line 61

define systemd::timer (
  Enum['present', 'absent', 'file']        $ensure = 'present',
  Stdlib::Absolutepath                     $path = '/etc/systemd/system',
  Optional[String[1]]                      $timer_content = undef,
  Optional[String[1]]                      $timer_source = undef,
  Optional[String[1]]                      $service_content = undef,
  Optional[String[1]]                      $service_source  = undef,
  String[1]                                $owner = 'root',
  String[1]                                $group = 'root',
  Stdlib::Filemode                         $mode = '0444',
  Optional[Systemd::Unit]                  $service_unit = undef,
  Boolean                                  $show_diff = true,
  Optional[Variant[Boolean, Enum['mask']]] $enable = undef,
  Optional[Boolean]                        $active = undef,
) {
  assert_type(Pattern['^.+\.timer$'],$name)

  if $service_unit {
    $_service_unit = $service_unit
  } else {
    $_service_unit = "${basename($name,'.timer')}.service"
  }

  if $service_content or $service_source {
    systemd::unit_file { $_service_unit:
      ensure    => $ensure,
      content   => $service_content,
      source    => $service_source,
      path      => $path,
      owner     => $owner,
      group     => $group,
      mode      => $mode,
      show_diff => $show_diff,
      before    => Systemd::Unit_File[$name],
    }
  }

  systemd::unit_file { $name:
    ensure    => $ensure,
    content   => $timer_content,
    source    => $timer_source,
    path      => $path,
    owner     => $owner,
    group     => $group,
    mode      => $mode,
    show_diff => $show_diff,
    enable    => $enable,
    active    => $active,
  }
}