Puppet Class: profile::backup::host

Defined in:
modules/profile/manifests/backup/host.pp

Overview

Profile class for adding backup functionalities to a host

Note that the hiera key lookups have a name space of profile::backup instead of profile::backup::host. That's cause they are reused in other profile classes in the same hierarchy and is consistent with our code guidelines

This profile class also does a small hack. It relies on profile::backup::enable being set to true before actually doing anything. That's because we can not provide meaningful default values for any of the other hiera calls, but still want to use the profile class in environments where backup is not set up. In that case we shortcircuit the class to be effectively a noop

Parameters:

  • enable (Boolean) (defaults to: lookup('profile::backup::enable'))
  • pool (String) (defaults to: lookup('profile::backup::pool'))
  • director (Stdlib::Host) (defaults to: lookup('profile::backup::director'))
  • days (Array[String]) (defaults to: lookup('profile::backup::days'))
  • director_seed (String) (defaults to: lookup('profile::backup::director_seed'))


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
# File 'modules/profile/manifests/backup/host.pp', line 13

class profile::backup::host(
    Boolean             $enable         = lookup('profile::backup::enable'),
    String              $pool           = lookup('profile::backup::pool'),
    Stdlib::Host        $director       = lookup('profile::backup::director'),
    Array[String]       $days           = lookup('profile::backup::days'),
    String              $director_seed  = lookup('profile::backup::director_seed'),
){

    if $enable {
        class { 'bacula::client':
            director         => $director,
            catalog          => 'production',
            file_retention   => '90 days',
            job_retention    => '90 days',
            directorpassword => fqdn_rand_string(32, '', $director_seed)
        }

        # This will use uniqueid fact to distribute (hopefully evenly) machines on
        # days of the week
        $day = inline_template('<%= @days[[@uniqueid].pack("H*").unpack("L")[0] % 7] -%>')

        $jobdefaults = "Monthly-1st-${day}-${pool}"

        # Realize the various virtual resources that may have been defined
        Bacula::Client::Job <| |> {
            require => Class['bacula::client'],
        }
        Motd::Script <| tag == 'backup-motd' |>

        # If the machine includes profile::firewall then let director connect to us
        firewall::service { "bacula-file-daemon-${director}":
            proto  => 'tcp',
            port   => 9102,
            srange => [$director],
        }
    }
}