2 class postgres::backup_server {
3 include postgres::backup_server::globals
6 # Regularly pull base backups
8 ensure_packages ( "postgresql-client-9.6", { ensure => 'installed' })
10 concat { $postgres::backup_server::globals::make_base_backups:
13 concat::fragment { 'make-base-backups-header':
14 target => $postgres::backup_server::globals::make_base_backups,
15 content => template('postgres/backup_server/postgres-make-base-backups.erb'),
18 Concat::Fragment <<| tag == $postgres::backup_server::globals::tag_base_backup |>>
19 concat::fragment { 'make-base-backups-tail':
20 target => $postgres::backup_server::globals::make_base_backups,
21 content => @(EOTEMPLATE),
22 # EOF by make-base-backups-tail fragment
27 file { '/etc/cron.d/puppet-postgres-make-base-backups': ensure => absent; }
28 file { '/var/lib/dsa/postgres-make-base-backups':
33 concat::fragment { 'dsa-puppet-stuff--postgres-make_base_backups':
34 target => '/etc/cron.d/dsa-puppet-stuff',
36 */30 * * * * debbackup sleep $(( RANDOM \% 1200 )); chronic ${$postgres::backup_server::globals::make_base_backups}
41 # Maintain authorized_keys file on backup servers for WAL shipping
43 # do not let other hosts directly build our authorized_keys file,
44 # instead go via a script that somewhat validates intput
45 file { '/etc/dsa/postgresql-backup':
46 ensure => 'directory',
48 file { '/usr/local/bin/postgres-make-backup-sshauthkeys':
49 content => template('postgres/backup_server/postgres-make-backup-sshauthkeys.erb'),
51 notify => Exec['postgres-make-backup-sshauthkeys'],
53 file { '/usr/local/bin/postgres-make-one-base-backup':
54 source => 'puppet:///modules/postgres/backup_server/postgres-make-one-base-backup',
57 file { '/etc/dsa/postgresql-backup/sshkeys-manual':
58 content => template('postgres/backup_server/sshkeys-manual.erb'),
59 notify => Exec['postgres-make-backup-sshauthkeys'],
61 concat { $postgres::backup_server::globals::sshkeys_sources:
62 notify => Exec['postgres-make-backup-sshauthkeys'],
64 concat::fragment { 'postgresql-backup/source-sshkeys-header':
65 target => $postgres::backup_server::globals::sshkeys_sources ,
67 # <name> <ip addresses> <key>
71 Concat::Fragment <<| tag == $postgres::backup_server::globals::tag_source_sshkey |>>
72 exec { "postgres-make-backup-sshauthkeys":
73 command => "/usr/local/bin/postgres-make-backup-sshauthkeys",
78 # Maintain /etc/nagios/dsa-check-backuppg.conf
80 file { '/etc/dsa/postgresql-backup/dsa-check-backuppg.conf.d':
81 ensure => 'directory',
85 source => 'puppet:///files/empty/',
86 notify => Exec['update dsa-check-backuppg-manual.conf'],
88 file { '/etc/dsa/postgresql-backup/dsa-check-backuppg.conf.d/manual.conf':
89 content => template('postgres/backup_server/dsa-check-backuppg-manual.conf.erb'),
90 notify => Exec['update dsa-check-backuppg-manual.conf']
92 File<<| tag == $postgres::backup_server::globals::tag_dsa_check_backupp |>>
93 ensure_packages ( "libhash-merge-simple-perl", { ensure => 'installed' })
94 exec { "update dsa-check-backuppg-manual.conf":
96 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
103 # Maintain .pgpass file on backup servers
105 concat { $postgres::backup_server::globals::pgpassfile:
106 owner => 'debbackup',
107 group => 'debbackup',
110 concat::fragment{ 'pgpass-local':
111 target => $postgres::backup_server::globals::pgpassfile,
112 source => '/home/debbackup/.pgpass-local',
115 Concat::Fragment <<| tag == $postgres::backup_server::globals::tag_source_pgpassline |>>