pg: put postgres ssh keys onto backup server
[mirror/dsa-puppet.git] / modules / postgres / manifests / backup_server.pp
index 9358cde..2bda5dc 100644 (file)
@@ -2,12 +2,47 @@ class postgres::backup_server {
        package { 'postgresql-client-9.1':
                ensure => installed
        }
+       package { 'postgresql-client-9.4':
+               ensure => installed
+       }
 
        file { '/usr/local/bin/postgres-make-base-backups':
-               source => 'puppet:///modules/postgres/backup_server/postgres-make-base-backups',
+               content => template('postgres/backup_server/postgres-make-base-backups.erb'),
                mode   => '0555',
        }
-       file { '/etc/cron.d/puppet-postgres-make-base-backups':
-               content  => "20 0 * * 6 debbackup chronic /usr/local/bin/postgres-make-base-backups\n",
+       if $::hostname in [backuphost] {
+               file { '/etc/cron.d/puppet-postgres-make-base-backups':
+                       content  => "20 1 * * 0 debbackup chronic /usr/local/bin/postgres-make-base-backups\n",
+               }
+       } else  {
+               file { '/etc/cron.d/puppet-postgres-make-base-backups':
+                       content  => "20 0 * * 6 debbackup chronic /usr/local/bin/postgres-make-base-backups\n",
+               }
+       }
+
+       file { '/etc/dsa/postgresql-backup':
+               ensure => 'directory',
+       }
+       file { '/usr/local/bin/postgres-make-backup-sshauthkeys':
+               content => template('postgres/backup_server/postgres-make-backup-sshauthkeys.erb'),
+               mode   => '0555',
+               notify  => Exec['postgres-make-backup-sshauthkeys'],
+       }
+       concat { '/etc/dsa/postgresql-backup/sshkeys-sources':
+               notify  => Exec['postgres-make-backup-sshauthkeys'],
+       }
+       concat::fragment { 'postgresql-backup/source-sshkeys-header':
+               target => '/etc/dsa/postgresql-backup/sshkeys-sources',
+               content  => @(EOF),
+                               # <name> <ip addresses> <key>
+                               | EOF
+               order  => '00',
+       }
+
+       Concat::Fragment <<| tag == "postgresql::server::backup-source-sshkey" |>>
+
+       exec { "postgres-make-backup-sshauthkeys":
+               command => "/usr/local/bin/postgres-make-backup-sshauthkeys",
+               refreshonly => true,
        }
 }