Puppet Class: profile::backup::director

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

Overview

Profile class for adding backup director functionalities to a host

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

Parameters:

  • pool (Any) (defaults to: hiera('profile::backup::pool'))
  • days (Any) (defaults to: hiera('profile::backup::days'))
  • offsite_pool (Any) (defaults to: hiera('profile::backup::director::offsite_pool'))
  • onsite_sd (Any) (defaults to: hiera('profile::backup::director::onsite_sd'))
  • offsite_sd (Any) (defaults to: hiera('profile::backup::director::offsite_sd'))
  • dbhost (Any) (defaults to: hiera('profile::backup::director::dbhost'))
  • dbschema (Any) (defaults to: hiera('profile::backup::director::dbschema'))
  • dbport (Any) (defaults to: hiera('profile::backup::director::dbport'))
  • dbuser (Any) (defaults to: hiera('profile::backup::director::dbuser'))
  • dbpass (Any) (defaults to: hiera('profile::backup::director::dbpass'))
  • prometheus_nodes (Any) (defaults to: hiera('prometheus_nodes'))


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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'modules/profile/manifests/backup/director.pp', line 6

class profile::backup::director(
    $pool = hiera('profile::backup::pool'),
    $days = hiera('profile::backup::days'),
    $offsite_pool = hiera('profile::backup::director::offsite_pool'),
    $onsite_sd = hiera('profile::backup::director::onsite_sd'),
    $offsite_sd = hiera('profile::backup::director::offsite_sd'),
    $dbhost = hiera('profile::backup::director::dbhost'),
    $dbschema = hiera('profile::backup::director::dbschema'),
    $dbport = hiera('profile::backup::director::dbport'),
    $dbuser = hiera('profile::backup::director::dbuser'),
    $dbpass = hiera('profile::backup::director::dbpass'),
    $prometheus_nodes = hiera('prometheus_nodes'),
){
    include ::profile::base::firewall

    class { 'bacula::director':
        sqlvariant          => 'mysql',
        max_dir_concur_jobs => '10',
    }

    if os_version('debian >= buster') {
        $file_storage_production = 'FileStorageProduction'
        $file_storage_archive = 'FileStorageArchive'
        $file_storage_databases = 'FileStorageDatabases'
        $scheduled_pools = [ $pool, 'Databases', ]
    } else {
        $file_storage_production = 'FileStorage1'
        $file_storage_archive = 'FileStorage2'
        $scheduled_pools = [ $pool, ]
    }

    # One pool for all, except databases
    bacula::director::pool { $pool:
        max_vols         => 70,
        storage          => "${onsite_sd}-${file_storage_production}",
        volume_retention => '90 days',
        label_fmt        => $pool,
        max_vol_bytes    => '536870912000',
        next_pool        => $offsite_pool,
    }

    # Default pool needed internally by bacula
    bacula::director::pool { 'Default':
        max_vols         => 1,
        storage          => "${onsite_sd}-${file_storage_production}",
        volume_retention => '1800 days',
    }

    # Archive pool for long term archival.
    bacula::director::pool { 'Archive':
        max_vols         => 5,
        storage          => "${onsite_sd}-${file_storage_archive}",
        volume_retention => '5 years',
        label_fmt        => 'archive',
        max_vol_bytes    => '536870912000',
    }

    # Databases-only pool
    if os_version('debian >= buster') {
        bacula::director::pool { 'Databases':
            max_vols         => 80,
            storage          => "${onsite_sd}-${file_storage_databases}",
            volume_retention => '90 days',
            label_fmt        => 'databases',
            max_vol_bytes    => '536870912000',
        }
    }

    # Off site pool for off site backups
    bacula::director::pool { $offsite_pool:
        max_vols         => 70,
        storage          => "${offsite_sd}-${file_storage_production}",
        volume_retention => '90 days',
        label_fmt        => $offsite_pool,
        max_vol_bytes    => '536870912000',
    }

    # One schedule per day of the week.
    # Setting execution times so that it is unlikely jobs will run concurrently
    # with cron.{hourly,daily,monthly} or other cronscripts
    $days.each |String $day| {
        # monthly
        backup::monthlyschedule { $day:  # schedules are pool-independent
            day => $day,
        }
        $scheduled_pools.each |String $scheduled_pool| {
            backup::monthlyjobdefaults { "${scheduled_pool}-${day}":
                day  => $day,
                pool => $scheduled_pool,
            }
        }
        # weekly
        backup::weeklyschedule { $day:
            day => $day,
        }
        $scheduled_pools.each |String $scheduled_pool| {
            backup::weeklyjobdefaults { "${scheduled_pool}-${day}":
                day  => $day,
                pool => $scheduled_pool,
            }
        }
        # hourly
        backup::hourlyschedule { $day:
            day => $day,
        }
        $scheduled_pools.each |String $scheduled_pool| {
            backup::hourlyjobdefaults { "${scheduled_pool}-${day}":
                day  => $day,
                pool => $scheduled_pool,
            }
        }
    }

    bacula::director::catalog { 'production':
        dbname     => $dbschema,
        dbuser     => $dbuser,
        dbhost     => $dbhost,
        dbport     => $dbport,
        dbpassword => $dbpass,
    }

    # The console should be on the director
    class { 'bacula::console':
        director   => $::fqdn,
    }

    nrpe::monitor_service { 'bacula_director':
        description  => 'bacula director process',
        nrpe_command => '/usr/lib/nagios/plugins/check_procs -w 1:1 -c 1:1 -u bacula -C bacula-dir',
        notes_url    => 'https://wikitech.wikimedia.org/wiki/Bacula#Monitoring',
    }

    # install the general backup check and set it up to run every hour
    class { 'bacula::director::check': }
    ::sudo::user { 'nagios_backup_freshness':
        user       => 'nagios',
        privileges => ['ALL = (bacula) NOPASSWD: /usr/bin/check_bacula.py'],
    }
    nrpe::monitor_service { 'backup_freshness':
        description    => 'Backup freshness',
        nrpe_command   => '/usr/bin/sudo -u bacula /usr/bin/check_bacula.py',
        critical       => false,
        contact_group  => 'admins',
        check_interval => 60,  # check every hour
        timeout        => 60,  # 1 minute of timeout, the check is not fast
        notes_url      => 'https://wikitech.wikimedia.org/wiki/Bacula#Monitoring',
    }

    # install the prometheus exporter for bacula
    class { 'bacula::director::prometheus_exporter':
        port => '9133',
    }
    base::service_auto_restart { 'prometheus-bacula-exporter': }

    ferm::service { 'bacula-director':
        proto  => 'tcp',
        port   => '9101',
        srange => '$PRODUCTION_NETWORKS',
    }
    $prometheus_nodes_ferm = join($prometheus_nodes, ' ')
    ferm::service { 'bacula-prometheus-exporter':
        proto  => 'tcp',
        port   => '9133',
        srange => "@resolve((${prometheus_nodes_ferm}))",
    }
}