summaryrefslogtreecommitdiff
path: root/manifests/setup.pp
blob: 360f73f9238bd5df720cb738aa018ebbe261c6f1 (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
# @summary Prepare for periodic rules to be loaded.
#
# @param periodic_dir
#   Directory in which periodic rules should be kept
# @param purge
#   Should the periodic directory be purged.
#   This means that unreferenced files will be deleted.
# @param suffix
#   Suffix of all "active" files in the periodic dir.
# @param ensure
#   Should the periodic dir be enabled.
class periodic::setup (
  Stdlib::Absolutepath $periodic_dir = '/usr/local/etc/periodic.conf.d',
  Boolean $purge = true,
  String $suffix = '.periodic',
  Enum['present', 'absent'] $ensure = 'present',
) {
  $content = @("EOF"/$)
    periodic_conf_files="${periodic_dir}/*${suffix} \${periodic_conf_files}"
    | EOF

  file { '/etc/periodic.conf':
    ensure => file,
  }

  # /etc/perodic.conf is included from /etc/defaults/peroidic.conf
  file_line { 'Periodic - Enable sourcing of files in directory':
    ensure => $ensure,
    path   => '/etc/periodic.conf',
    line   => $content,
  }

  file { $periodic_dir:
    ensure => if $ensure == 'present' { 'directory' } else { 'absent' },
    purge  => $purge,
  }
}