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:
24 concat::fragment { 'make-base-backups-header':
25 target => $postgres::backup_server::globals::make_base_backups,
26 content => template('postgres/backup_server/postgres-make-base-backups.erb'),
29 Concat::Fragment <<| tag == $postgres::backup_server::globals::tag_base_backup |>>
30 concat::fragment { 'make-base-backups-tail':
31 target => $postgres::backup_server::globals::make_base_backups,
32 content => @(EOTEMPLATE),
33 # EOF by make-base-backups-tail fragment
38 if $::hostname in [backuphost] {
39 file { '/etc/cron.d/puppet-postgres-make-base-backups':
40 content => "20 1 * * 0 debbackup chronic ${$postgres::backup_server::globals::make_base_backups}\n",
43 file { '/etc/cron.d/puppet-postgres-make-base-backups':
44 content => "20 0 * * 6 debbackup chronic ${$postgres::backup_server::globals::make_base_backups}\n",
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 { '/etc/dsa/postgresql-backup/sshkeys-manual':
61 content => template('postgres/backup_server/sshkeys-manual.erb'),
62 notify => Exec['postgres-make-backup-sshauthkeys'],
64 concat { $postgres::backup_server::globals::sshkeys_sources:
65 notify => Exec['postgres-make-backup-sshauthkeys'],
67 concat::fragment { 'postgresql-backup/source-sshkeys-header':
68 target => $postgres::backup_server::globals::sshkeys_sources ,
70 # <name> <ip addresses> <key>
74 Concat::Fragment <<| tag == $postgres::backup_server::globals::tag_source_sshkey |>>
75 exec { "postgres-make-backup-sshauthkeys":
76 command => "/usr/local/bin/postgres-make-backup-sshauthkeys",
80 # Maintain .pgpass file on backup servers
81 concat { $postgres::backup_server::globals::pgpassfile:
86 concat::fragment{ 'pgpass-local':
87 target => $postgres::backup_server::globals::pgpassfile,
88 source => '/home/debbackup/.pgpass-local',
91 Concat::Fragment <<| tag == $postgres::backup_server::globals::tag_source_pgpassline |>>
94 define postgres::backup_server::register_backup_clienthost (
95 $sshpubkey = $::postgresql_key,
96 $ipaddrlist = join(getfromhash($site::nodeinfo, 'ldap', 'ipHostNumber'), ","),
97 $hostname = $::hostname,
99 include postgres::backup_server::globals
102 $addr = assert_type(String[1], $ipaddrlist)
103 @@concat::fragment { "postgresql::server::backup-source-clienthost::$name::$fqdn":
104 target => $postgres::backup_server::globals::sshkeys_sources ,
106 ${hostname} ${addr} ${sshpubkey}
108 tag => $postgres::backup_server::globals::tag_source_sshkey,
113 define postgres::backup_server::register_backup_cluster (
121 include postgres::backup_server::globals
123 # foobar.debian.org:5432:*:debian-backup:swordfish
124 @@concat::fragment { "postgresql::server::backup-source-pgpassline::$hostname::$pg_port::$pg_role":
125 target => $postgres::backup_server::globals::pgpassfile,
127 ${hostname}:${pg_port}:*:${pg_role}:${pg_password}
129 tag => $postgres::backup_server::globals::tag_source_pgpassline,
132 # vittoria.debian.org 5432 debian-backup main 9.6
133 @@concat::fragment { "postgresql::server::backup-source-make-base-backup-entry::$hostname::$pg_port::$pg_role":
134 target => $postgres::backup_server::globals::make_base_backups,
136 ${hostname} ${pg_port} ${pg_role} ${pg_cluster} ${pg_version}
138 tag => $postgres::backup_server::globals::tag_base_backup,