2 class postgres::backup_server {
3 include postgres::backup_server::globals
6 'libhash-merge-simple-perl',
11 'postgresql-client-9.6',
17 # Regularly pull base backups
19 concat { $postgres::backup_server::globals::make_base_backups:
22 concat::fragment { 'make-base-backups-header':
23 target => $postgres::backup_server::globals::make_base_backups,
24 content => template('postgres/backup_server/postgres-make-base-backups.erb'),
27 Concat::Fragment <<| tag == $postgres::backup_server::globals::tag_base_backup |>>
28 concat::fragment { 'make-base-backups-tail':
29 target => $postgres::backup_server::globals::make_base_backups,
30 content => @(EOTEMPLATE),
31 # EOF by make-base-backups-tail fragment
36 file { '/etc/cron.d/puppet-postgres-make-base-backups': ensure => absent; }
37 file { '/var/lib/dsa/postgres-make-base-backups':
42 concat::fragment { 'dsa-puppet-stuff--postgres-make_base_backups':
43 target => '/etc/cron.d/dsa-puppet-stuff',
45 */30 * * * * debbackup sleep $(( RANDOM \% 1200 )); chronic ${$postgres::backup_server::globals::make_base_backups}
50 # Maintain authorized_keys file on backup servers for WAL shipping
52 # do not let other hosts directly build our authorized_keys file,
53 # instead go via a script that somewhat validates intput
54 file { '/etc/dsa/postgresql-backup':
55 ensure => 'directory',
57 file { '/usr/local/bin/postgres-make-backup-sshauthkeys':
58 content => template('postgres/backup_server/postgres-make-backup-sshauthkeys.erb'),
60 notify => Exec['postgres-make-backup-sshauthkeys'],
62 file { '/usr/local/bin/postgres-make-one-base-backup':
63 source => 'puppet:///modules/postgres/backup_server/postgres-make-one-base-backup',
66 file { '/etc/dsa/postgresql-backup/sshkeys-manual':
67 content => template('postgres/backup_server/sshkeys-manual.erb'),
68 notify => Exec['postgres-make-backup-sshauthkeys'],
70 concat { $postgres::backup_server::globals::sshkeys_sources:
71 notify => Exec['postgres-make-backup-sshauthkeys'],
73 concat::fragment { 'postgresql-backup/source-sshkeys-header':
74 target => $postgres::backup_server::globals::sshkeys_sources ,
76 # <name> <ip addresses> <key>
80 Concat::Fragment <<| tag == $postgres::backup_server::globals::tag_source_sshkey |>>
81 exec { "postgres-make-backup-sshauthkeys":
82 command => "/usr/local/bin/postgres-make-backup-sshauthkeys",
87 # Maintain /etc/nagios/dsa-check-backuppg.conf
89 file { '/etc/dsa/postgresql-backup/dsa-check-backuppg.conf.d':
90 ensure => 'directory',
94 source => 'puppet:///files/empty/',
95 notify => Exec['update dsa-check-backuppg-manual.conf'],
97 file { '/etc/dsa/postgresql-backup/dsa-check-backuppg.conf.d/manual.conf':
98 content => template('postgres/backup_server/dsa-check-backuppg-manual.conf.erb'),
99 notify => Exec['update dsa-check-backuppg-manual.conf']
101 File<<| tag == $postgres::backup_server::globals::tag_dsa_check_backupp |>>
102 exec { "update dsa-check-backuppg-manual.conf":
104 perl -MYAML=LoadFile,Dump -MHash::Merge::Simple=merge -E 'say Dump(merge(map{LoadFile($_)}@ARGV))' /etc/dsa/postgresql-backup/dsa-check-backuppg.conf.d/*.conf > /etc/nagios/dsa-check-backuppg.conf
111 # Maintain .pgpass file on backup servers
113 concat { $postgres::backup_server::globals::pgpassfile:
114 owner => 'debbackup',
115 group => 'debbackup',
118 concat::fragment{ 'pgpass-local':
119 target => $postgres::backup_server::globals::pgpassfile,
120 source => '/home/debbackup/.pgpass-local',
123 Concat::Fragment <<| tag == $postgres::backup_server::globals::tag_source_pgpassline |>>