ship pg backup sshkeys in puppet
[mirror/dsa-puppet.git] / modules / postgres / manifests / backup_server.pp
1 class postgres::backup_server {
2         package { 'postgresql-client-9.1':
3                 ensure => installed
4         }
5         package { 'postgresql-client-9.4':
6                 ensure => installed
7         }
8
9         file { '/usr/local/bin/postgres-make-base-backups':
10                 content => template('postgres/backup_server/postgres-make-base-backups.erb'),
11                 mode   => '0555',
12         }
13         if $::hostname in [backuphost] {
14                 file { '/etc/cron.d/puppet-postgres-make-base-backups':
15                         content  => "20 1 * * 0 debbackup chronic /usr/local/bin/postgres-make-base-backups\n",
16                 }
17         } else  {
18                 file { '/etc/cron.d/puppet-postgres-make-base-backups':
19                         content  => "20 0 * * 6 debbackup chronic /usr/local/bin/postgres-make-base-backups\n",
20                 }
21         }
22
23         file { '/etc/dsa/postgresql-backup':
24                 ensure => 'directory',
25         }
26         file { '/usr/local/bin/postgres-make-backup-sshauthkeys':
27                 content => template('postgres/backup_server/postgres-make-backup-sshauthkeys.erb'),
28                 mode   => '0555',
29                 notify  => Exec['postgres-make-backup-sshauthkeys'],
30         }
31         file { '/etc/dsa/postgresql-backup/sshkeys-manual':
32                 content => template('postgres/backup_server/sshkeys-manual.erb'),
33                 notify  => Exec['postgres-make-backup-sshauthkeys'],
34         }
35         concat { '/etc/dsa/postgresql-backup/sshkeys-sources':
36                 notify  => Exec['postgres-make-backup-sshauthkeys'],
37         }
38         concat::fragment { 'postgresql-backup/source-sshkeys-header':
39                 target => '/etc/dsa/postgresql-backup/sshkeys-sources',
40                 content  => @(EOF),
41                                 # <name> <ip addresses> <key>
42                                 | EOF
43                 order  => '00',
44         }
45
46         Concat::Fragment <<| tag == "postgresql::server::backup-source-sshkey" |>>
47
48         exec { "postgres-make-backup-sshauthkeys":
49                 command => "/usr/local/bin/postgres-make-backup-sshauthkeys",
50                 refreshonly => true,
51         }
52 }