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"
12 class postgres::backup_server {
13 include postgres::backup_server::globals
15 package { 'postgresql-client-9.1':
18 package { 'postgresql-client-9.4':
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 if $::hostname in [backuphost] {
40 file { '/etc/cron.d/puppet-postgres-make-base-backups':
41 content => "20 1 * * 0 debbackup chronic ${$postgres::backup_server::globals::make_base_backups}\n",
44 file { '/etc/cron.d/puppet-postgres-make-base-backups':
45 content => "20 0 * * 6 debbackup chronic ${$postgres::backup_server::globals::make_base_backups}\n",
49 # Maintain authorized_keys file on backup servers for WAL shipping
51 # do not let other hosts directly build our authorized_keys file,
52 # instead go via a script that somewhat validates intput
53 file { '/etc/dsa/postgresql-backup':
54 ensure => 'directory',
56 file { '/usr/local/bin/postgres-make-backup-sshauthkeys':
57 content => template('postgres/backup_server/postgres-make-backup-sshauthkeys.erb'),
59 notify => Exec['postgres-make-backup-sshauthkeys'],
61 file { '/etc/dsa/postgresql-backup/sshkeys-manual':
62 content => template('postgres/backup_server/sshkeys-manual.erb'),
63 notify => Exec['postgres-make-backup-sshauthkeys'],
65 concat { $postgres::backup_server::globals::sshkeys_sources:
66 notify => Exec['postgres-make-backup-sshauthkeys'],
68 concat::fragment { 'postgresql-backup/source-sshkeys-header':
69 target => $postgres::backup_server::globals::sshkeys_sources ,
71 # <name> <ip addresses> <key>
75 Concat::Fragment <<| tag == $postgres::backup_server::globals::tag_source_sshkey |>>
76 exec { "postgres-make-backup-sshauthkeys":
77 command => "/usr/local/bin/postgres-make-backup-sshauthkeys",
81 # Maintain .pgpass file on backup servers
82 concat { $postgres::backup_server::globals::pgpassfile:
87 concat::fragment{ 'pgpass-local':
88 target => $postgres::backup_server::globals::pgpassfile,
89 source => '/home/debbackup/.pgpass-local',
92 Concat::Fragment <<| tag == $postgres::backup_server::globals::tag_source_pgpassline |>>
95 define postgres::backup_server::register_backup_clienthost (
96 $sshpubkey = $::postgresql_key,
97 $ipaddrlist = join(getfromhash($site::nodeinfo, 'ldap', 'ipHostNumber'), ","),
98 $hostname = $::hostname,
100 include postgres::backup_server::globals
103 $addr = assert_type(String[1], $ipaddrlist)
104 @@concat::fragment { "postgresql::server::backup-source-clienthost::$name::$fqdn":
105 target => $postgres::backup_server::globals::sshkeys_sources ,
107 ${hostname} ${addr} ${sshpubkey}
109 tag => $postgres::backup_server::globals::tag_source_sshkey,
114 define postgres::backup_server::register_backup_cluster (
122 include postgres::backup_server::globals
124 # foobar.debian.org:5432:*:debian-backup:swordfish
125 @@concat::fragment { "postgresql::server::backup-source-pgpassline::$hostname::$pg_port::$pg_role":
126 target => $postgres::backup_server::globals::pgpassfile,
128 ${hostname}:${pg_port}:*:${pg_role}:${pg_password}
130 tag => $postgres::backup_server::globals::tag_source_pgpassline,
133 # vittoria.debian.org 5432 debian-backup main 9.6
134 @@concat::fragment { "postgresql::server::backup-source-make-base-backup-entry::$hostname::$pg_port::$pg_role":
135 target => $postgres::backup_server::globals::make_base_backups,
137 ${hostname} ${pg_port} ${pg_role} ${pg_cluster} ${pg_version}
139 tag => $postgres::backup_server::globals::tag_base_backup,