2 class postgres::backup_server::globals {
3 $make_base_backups = '/usr/local/bin/postgres-make-base-backups'
4 $pgpassfile = '/home/debbackup/.pgpass'
5 $sshkeys_sources = '/etc/dsa/postgresql-backup/sshkeys-sources'
7 $tag_base_backup = "postgresql::server::backup-source-make-base-backup-entry"
8 $tag_source_sshkey = "postgresql::server::backup-source-sshkey"
9 $tag_source_pgpassline = "postgresql::server::backup-source-pgpassline"
10 $tag_dsa_check_backupp = "postgresql::server::backup-dsa-check-backuppg"
13 class postgres::backup_server {
14 include postgres::backup_server::globals
17 # Regularly pull base backups
19 ensure_packages ( "postgresql-client-9.1", { ensure => 'installed' })
20 ensure_packages ( "postgresql-client-9.4", { ensure => 'installed' })
22 concat { $postgres::backup_server::globals::make_base_backups:
25 concat::fragment { 'make-base-backups-header':
26 target => $postgres::backup_server::globals::make_base_backups,
27 content => template('postgres/backup_server/postgres-make-base-backups.erb'),
30 Concat::Fragment <<| tag == $postgres::backup_server::globals::tag_base_backup |>>
31 concat::fragment { 'make-base-backups-tail':
32 target => $postgres::backup_server::globals::make_base_backups,
33 content => @(EOTEMPLATE),
34 # EOF by make-base-backups-tail fragment
39 file { '/etc/cron.d/puppet-postgres-make-base-backups': ensure => absent; }
40 concat::fragment { 'dsa-puppet-stuff--postgres-make_base_backups':
41 target => '/etc/cron.d/dsa-puppet-stuff',
43 */10 * * * 0 debbackup chronic ${$postgres::backup_server::globals::make_base_backups}
48 # Maintain authorized_keys file on backup servers for WAL shipping
50 # do not let other hosts directly build our authorized_keys file,
51 # instead go via a script that somewhat validates intput
52 file { '/etc/dsa/postgresql-backup':
53 ensure => 'directory',
55 file { '/usr/local/bin/postgres-make-backup-sshauthkeys':
56 content => template('postgres/backup_server/postgres-make-backup-sshauthkeys.erb'),
58 notify => Exec['postgres-make-backup-sshauthkeys'],
60 file { '/usr/local/bin/postgres-make-one-base-backup':
61 source => 'puppet:///modules/postgres/backup_server/postgres-make-one-base-backup',
64 file { '/etc/dsa/postgresql-backup/sshkeys-manual':
65 content => template('postgres/backup_server/sshkeys-manual.erb'),
66 notify => Exec['postgres-make-backup-sshauthkeys'],
68 concat { $postgres::backup_server::globals::sshkeys_sources:
69 notify => Exec['postgres-make-backup-sshauthkeys'],
71 concat::fragment { 'postgresql-backup/source-sshkeys-header':
72 target => $postgres::backup_server::globals::sshkeys_sources ,
74 # <name> <ip addresses> <key>
78 Concat::Fragment <<| tag == $postgres::backup_server::globals::tag_source_sshkey |>>
79 exec { "postgres-make-backup-sshauthkeys":
80 command => "/usr/local/bin/postgres-make-backup-sshauthkeys",
85 # Maintain /etc/nagios/dsa-check-backuppg.conf
87 file { '/etc/dsa/postgresql-backup/dsa-check-backuppg.conf.d':
88 ensure => 'directory',
92 source => 'puppet:///files/empty/',
93 notify => Exec['update dsa-check-backuppg-manual.conf'],
95 file { '/etc/dsa/postgresql-backup/dsa-check-backuppg.conf.d/manual.conf':
96 content => template('postgres/backup_server/dsa-check-backuppg-manual.conf.erb'),
97 notify => Exec['update dsa-check-backuppg-manual.conf']
99 file { '/etc/dsa/postgresql-backup/dsa-check-backuppg.conf.d/moszumanska.conf':
100 ensure => ($::hostname in [backuphost]) ? {
110 notify => Exec['update dsa-check-backuppg-manual.conf']
112 File<<| tag == $postgres::backup_server::globals::tag_dsa_check_backupp |>>
113 ensure_packages ( "libhash-merge-simple-perl", { ensure => 'installed' })
114 exec { "update dsa-check-backuppg-manual.conf":
116 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
123 # Maintain .pgpass file on backup servers
125 concat { $postgres::backup_server::globals::pgpassfile:
126 owner => 'debbackup',
127 group => 'debbackup',
130 concat::fragment{ 'pgpass-local':
131 target => $postgres::backup_server::globals::pgpassfile,
132 source => '/home/debbackup/.pgpass-local',
135 Concat::Fragment <<| tag == $postgres::backup_server::globals::tag_source_pgpassline |>>
138 define postgres::backup_server::register_backup_clienthost (
139 $sshpubkey = $::postgresql_key,
140 $ipaddrlist = join(getfromhash($site::nodeinfo, 'ldap', 'ipHostNumber'), ","),
141 $hostname = $::hostname,
143 include postgres::backup_server::globals
146 $addr = assert_type(String[1], $ipaddrlist)
147 @@concat::fragment { "postgresql::server::backup-source-clienthost::$name::$fqdn":
148 target => $postgres::backup_server::globals::sshkeys_sources ,
150 ${hostname} ${addr} ${sshpubkey}
152 tag => $postgres::backup_server::globals::tag_source_sshkey,
157 define postgres::backup_server::register_backup_cluster (
158 $hostname = $::hostname,
166 include postgres::backup_server::globals
168 # foobar.debian.org:5432:*:debian-backup:swordfish
169 @@concat::fragment { "postgresql::server::backup-source-pgpassline::$hostname::$pg_port::$pg_role":
170 target => $postgres::backup_server::globals::pgpassfile,
172 ${fqdn}:${pg_port}:*:${pg_role}:${pg_password}
174 tag => $postgres::backup_server::globals::tag_source_pgpassline,
177 # vittoria.debian.org 5432 debian-backup main 9.6
178 @@concat::fragment { "postgresql::server::backup-source-make-base-backup-entry::$hostname::$pg_port::$pg_role":
179 target => $postgres::backup_server::globals::make_base_backups,
181 ${fqdn} ${pg_port} ${pg_role} ${pg_cluster} ${pg_version}
183 tag => $postgres::backup_server::globals::tag_base_backup,
186 @@file { "/etc/dsa/postgresql-backup/dsa-check-backuppg.conf.d/${hostname}-${pg_cluster}.conf":
193 tag => $postgres::backup_server::globals::tag_dsa_check_backupp,
194 notify => Exec['update dsa-check-backuppg-manual.conf']