File: timer.pp

package info (click to toggle)
puppet-module-camptocamp-systemd 2.12.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 680 kB
  • sloc: ruby: 1,094; sh: 10; makefile: 4
file content (106 lines) | stat: -rw-r--r-- 3,188 bytes parent folder | download
1
2
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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
# @summary Create a timer and optionally a service unit to execute with the timer unit
#
# @api public
#
# @see https://www.freedesktop.org/software/systemd/man/systemd.timer.html systemd.timer(5)
#
# @param name [Pattern['^.+\.timer$]]
#   The target of the timer unit to create
#
# @param path
#   The main systemd configuration path
#
# @param timer_content
#   The full content of the timer unit file
#
#   * Mutually exclusive with ``$timer_source``
#
# @param timer_source
#   The ``File`` resource compatible ``source``
#
#   * Mutually exclusive with ``$timer_content``
#
# @param service_content
#   The full content of the service unit file
#
#   * Mutually exclusive with ``$service_source``
#
# @param service_source
#   The ``File`` resource compatible ``source``
#
#   * Mutually exclusive with ``$service_content``
#
# @param owner
#   The owner to set on the dropin file
#
# @param group
#   The group to set on the dropin file
#
# @param mode
#   The mode to set on the dropin file
#
# @param show_diff
#   Whether to show the diff when updating dropin file
#
# @param service_unit
#   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/
#
# @param active
#  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.
#
# @param enable
#   If set, will manage the state of the unit.
#
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,
    }
  }

  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,
  }
}