24647a3b1151046bfa41dfd6aa50b1f2d74be8c7
[mirror/dsa-puppet.git] / modules / salsa / manifests / database.pp
1 #
2 class salsa::database inherits salsa {
3         class { 'postgresql::globals':
4                 version => '9.6',
5         }
6         class { 'postgresql::server':
7                 listen_addresses => '*',
8         }
9         class { 'postgresql::server::contrib': }
10
11         postgresql::server::db { $salsa::db_name:
12                 user     => $salsa::db_role,
13                 password => postgresql_password($salsa::db_role, $salsa::db_password),
14         }
15
16         postgresql::server::extension { 'pg_trgm':
17                 database => $salsa::db_name,
18                 require => Class['postgresql::server::contrib'],
19         }
20
21         $pg_config_options = {
22                 'track_counts'  => 'yes',
23                 'archive_mode' => 'yes',
24                 'wal_level' => 'archive',
25                 'max_wal_senders' => '3',
26                 'archive_timeout' => '1h',
27                 'archive_command' => '/usr/local/bin/pg-backup-file main WAL %p',
28                 'ssl' => 'on',
29                 'ssl_cert_file' => '/etc/ssl/debian/certs/thishost-server.crt',
30                 'ssl_key_file' => '/etc/ssl/private/thishost-server.key',
31         }
32         $pg_config_options.each |String $key, String $value| {
33                 postgresql_conf { $key:
34                         value => $value,
35                         target => $postgresql::params::postgresql_conf_path,
36                         notify => Service['postgresqld'],
37                 }
38         }
39
40         include postgres::backup_source
41
42         postgres::backup_cluster { $::hostname:
43                 pg_version => $postgresql::params::version,
44                 pg_port => $postgresql::params::port,
45                 do_role => true,
46                 do_hba => true,
47         }
48
49         include postgres::backup_server::register_backup_clienthost
50 }