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
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 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'modules/profile/manifests/backup/director.pp', line 6
class profile::backup::director(
String $pool = lookup('profile::backup::pool'),
Array[String] $days = lookup('profile::backup::days'),
String $offsite_pool = lookup('profile::backup::director::offsite_pool'),
String $onsite_sd = lookup('profile::backup::director::onsite_sd'),
String $offsite_sd = lookup('profile::backup::director::offsite_sd'),
Stdlib::Host $dbhost = lookup('profile::backup::director::dbhost'),
String $dbschema = lookup('profile::backup::director::dbschema'),
Stdlib::Port $dbport = lookup('profile::backup::director::dbport'),
String $dbuser = lookup('profile::backup::director::dbuser'),
String $dbpass = lookup('profile::backup::director::dbpass'),
){
include profile::firewall
class { 'bacula::director':
sqlvariant => 'mysql',
max_dir_concur_jobs => '10',
}
# FIXME: When we do multisite, these should be handled better
$file_storage_production = 'FileStorageProductionEqiad'
$file_storage_archive = 'FileStorageArchiveEqiad'
# Default pool for "normal" backups (not archivals or database-related)
bacula::director::pool { $pool:
max_vols => 120,
storage => "${onsite_sd}-${file_storage_production}",
volume_retention => '90 days',
label_fmt => $pool,
max_vol_bytes => '536870912000',
}
# old production pool, to be removed in 60 days
bacula::director::pool { 'OldProduction':
max_vols => 70,
storage => 'backup1001-FileStorageProduction',
volume_retention => '90 days',
label_fmt => 'production',
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 { 'ArchiveEqiad':
max_vols => 5,
storage => "${onsite_sd}-${file_storage_archive}",
volume_retention => '5 years',
label_fmt => 'archiveEqiad',
max_vol_bytes => '536870912000',
}
# Old Archive pool for long term archival - to be removed when migrated to the above
bacula::director::pool { 'OldArchive':
max_vols => 5,
storage => 'backup1001-FileStorageArchive',
volume_retention => '5 years',
label_fmt => 'archive',
max_vol_bytes => '536870912000',
}
# TODO: This will probably be later a per-dc hiera key
$databases_sd_eqiad = 'backup1008'
$databases_sd_codfw = 'backup2008'
# Database dumps-only pool
bacula::director::pool { 'DatabasesEqiad':
max_vols => 95, # increase if size > 50 TB
storage => "${databases_sd_eqiad}-FileStorageDumpsEqiad",
volume_retention => '90 days',
label_fmt => 'databases-eqiad',
max_vol_bytes => '536870912000',
}
bacula::director::pool { 'DatabasesCodfw':
max_vols => 95, # increase if size > 50 TB
storage => "${databases_sd_codfw}-FileStorageDumpsCodfw",
volume_retention => '90 days',
label_fmt => 'databases-codfw',
max_vol_bytes => '536870912000',
}
# Old databases pool, kept as read-only (for recovery purposes only).
# Temporary, to be removed after 60 days pass.
bacula::director::pool { 'OldDatabasesEqiad':
max_vols => 95,
storage => 'backup1001-FileStorageDatabases',
volume_retention => '90 days',
label_fmt => 'databases',
max_vol_bytes => '536870912000',
}
bacula::director::pool { 'OldDatabasesCodfw':
max_vols => 95,
storage => 'backup2001-FileStorageDatabasesCodfw',
volume_retention => '90 days',
label_fmt => 'databases-codfw',
max_vol_bytes => '536870912000',
}
# TODO: config codfw pool when there is dual directors
# Off site pool for off site backups
bacula::director::pool { $offsite_pool:
max_vols => 70,
storage => "${offsite_sd}-FileStorageProduction",
volume_retention => '90 days',
label_fmt => $offsite_pool,
max_vol_bytes => '536870912000',
}
# Eqiad pool for read-only External Storage backups
bacula::director::pool { 'EsRoEqiad':
max_vols => 50,
storage => 'backup1003-FileStorageEsRoEqiad',
volume_retention => '5 years',
label_fmt => 'es-ro-eqiad',
max_vol_bytes => '536870912000',
}
# Codfw pool for read-only External Storage backups
bacula::director::pool { 'EsRoCodfw':
max_vols => 50,
storage => 'backup2003-FileStorageEsRoCodfw',
volume_retention => '5 years',
label_fmt => 'es-ro-codfw',
max_vol_bytes => '536870912000',
}
# Eqiad pool for read-write External storage backups
bacula::director::pool { 'EsRwEqiad':
max_vols => 250,
storage => 'backup1003-FileStorageEsRwEqiad',
volume_retention => '90 days',
label_fmt => 'es-rw-eqiad',
max_vol_bytes => '536870912000',
}
# Codfw pool for read-write External storage backups
bacula::director::pool { 'EsRwCodfw':
max_vols => 250,
storage => 'backup2003-FileStorageEsRwCodfw',
volume_retention => '90 days',
label_fmt => 'es-rw-codfw',
max_vol_bytes => '536870912000',
}
# Predefined schedules
$days.each |String $day| {
# monthly
backup::monthlyschedule { $day: # schedules are pool-independent
day => $day,
}
# weekly
backup::weeklyschedule { $day:
day => $day,
}
# hourly
backup::hourlyschedule { $day:
day => $day,
}
}
# daily (does not require a day)
backup::dailyschedule {'Daily': }
# Predefined jobdefaults for the default pool.
$days.each |String $day| {
# monthly
backup::monthlyjobdefaults { "${pool}-${day}":
day => $day,
pool => $pool,
}
backup::weeklyjobdefaults { "${pool}-${day}":
day => $day,
pool => $pool,
}
backup::hourlyjobdefaults { "${pool}-${day}":
day => $day,
pool => $pool,
}
}
# Jobdefaults ready for one time Archive-like backups
# Use it like this on a profile:
# backup::set { '<set-of-files-and-dirs-name>':
# jobdefaults => 'Weekly-Mon-ArchiveEqiad',
# }
# then execute 'run' on the backup director
$one_time_backup_day = 'Mon'
backup::weeklyjobdefaults { "Weekly-${one_time_backup_day}-ArchiveEqiad":
day => $one_time_backup_day,
pool => 'ArchiveEqiad',
}
# jobdefaults ready for one time ro backups
backup::weeklyjobdefaults { "Weekly-${one_time_backup_day}-EsRoEqiad":
day => $one_time_backup_day,
pool => 'EsRoEqiad',
}
backup::weeklyjobdefaults { "Weekly-${one_time_backup_day}-EsRoCodfw":
day => $one_time_backup_day,
pool => 'EsRoCodfw',
}
# Jobdefaults for metadata Database backups
$metadata_db_backup_day = 'Wed'
backup::weeklyjobdefaults { "Weekly-${metadata_db_backup_day}-DatabasesEqiad":
day => $metadata_db_backup_day,
pool => 'DatabasesEqiad',
}
backup::weeklyjobdefaults { "Weekly-${metadata_db_backup_day}-DatabasesCodfw":
day => $metadata_db_backup_day,
pool => 'DatabasesCodfw',
}
$es_db_backup_day = 'Thu'
backup::weeklyjobdefaults { "Weekly-${es_db_backup_day}-EsRwEqiad":
day => $es_db_backup_day,
pool => 'EsRwEqiad',
}
backup::weeklyjobdefaults { "Weekly-${es_db_backup_day}-EsRwCodfw":
day => $es_db_backup_day,
pool => 'EsRwCodfw',
}
# Jobdefaults for Gitlab (full backups every day)
backup::dailyjobdefaults { "Daily-${pool}":
pool => $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 => $facts['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': }
nrpe::monitor_service { 'backup_freshness':
description => 'Backup freshness',
nrpe_command => '/usr/bin/check_bacula.py --icinga',
sudo_user => 'bacula',
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',
}
profile::auto_restarts::service { 'prometheus-bacula-exporter': }
file { '/etc/bacula/job_monitoring_ignorelist':
ensure => present,
source => 'puppet:///modules/profile/backup/job_monitoring_ignorelist',
owner => 'bacula',
group => 'bacula',
mode => '0550',
}
ferm::service { 'bacula-director':
proto => 'tcp',
port => '9101',
srange => '$PRODUCTION_NETWORKS',
}
}
|