summaryrefslogtreecommitdiff
path: root/manifests/init.pp
blob: 84b40aabc184fb932db70a2068e93e572e645790 (plain)
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
# @summary Enable a pre-existing periodic rule
# @param value
#   Target value for parameter.
#   Strings will be double quoted, meaning that shell expansions will
#   be done in them at the time of use. Integers will be interpreted
#   inserted literally.
#
#   This is most often set to "YES" or "NO"
#
# @param key
#   The actually name to set. Valid values depen on available
#   periodic files.
# @param ensure
#   Should the resource be added or removed.
#   Note that if `periodic::setup::purge` is true then simply removing
#   the puppet declaratipurges the rule.
define periodic (
  Variant[String, Integer] $value,
  String $key = $name,
  Enum['present', 'absent'] $ensure = 'present',
) {
  include periodic::setup

  $file = "${periodic::setup::periodic_dir}/${key}${periodic::setup::suffix}"

  $value_ = $value ? {
    Integer => $value,
    String  => "\"${value}\"",
  }

  file { $file:
    ensure  => $ensure,
    content => epp("${module_name}/periodic-entry", {
        key   => $key,
        value => $value_
    }),
  }
}