roles::postgresql::server now sets up postgres::cluster for all clusters
[mirror/dsa-puppet.git] / modules / salsa / manifests / database.pp
index 0d22449..24647a3 100644 (file)
@@ -1,7 +1,12 @@
 #
 class salsa::database inherits salsa {
-       include postgresql::server
-       ensure_packages ( "postgresql-contrib-9.6", { ensure => 'installed' })
+       class { 'postgresql::globals':
+               version => '9.6',
+       }
+       class { 'postgresql::server':
+               listen_addresses => '*',
+       }
+       class { 'postgresql::server::contrib': }
 
        postgresql::server::db { $salsa::db_name:
                user     => $salsa::db_role,
@@ -10,11 +15,36 @@ class salsa::database inherits salsa {
 
        postgresql::server::extension { 'pg_trgm':
                database => $salsa::db_name,
-               require => Package['postgresql-contrib-9.6'],
+               require => Class['postgresql::server::contrib'],
        }
 
-       # XXX set up backups
-       file { "/var/lib/postgresql/9.6/main/.nobackup":
-               content  => ""
+       $pg_config_options = {
+               'track_counts'  => 'yes',
+               'archive_mode' => 'yes',
+               'wal_level' => 'archive',
+               'max_wal_senders' => '3',
+               'archive_timeout' => '1h',
+               'archive_command' => '/usr/local/bin/pg-backup-file main WAL %p',
+               'ssl' => 'on',
+               'ssl_cert_file' => '/etc/ssl/debian/certs/thishost-server.crt',
+               'ssl_key_file' => '/etc/ssl/private/thishost-server.key',
        }
+       $pg_config_options.each |String $key, String $value| {
+               postgresql_conf { $key:
+                       value => $value,
+                       target => $postgresql::params::postgresql_conf_path,
+                       notify => Service['postgresqld'],
+               }
+       }
+
+       include postgres::backup_source
+
+       postgres::backup_cluster { $::hostname:
+               pg_version => $postgresql::params::version,
+               pg_port => $postgresql::params::port,
+               do_role => true,
+               do_hba => true,
+       }
+
+       include postgres::backup_server::register_backup_clienthost
 }