e2793c1e2b71b404dd459364ceb2c161543ae756
[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         include postgres::backup_source
22         $datadir = assert_type(String[1], $postgresql::params::datadir)
23         warning("foo ")
24         file { "${datadir}/.nobackup":
25                 content  => ""
26         }
27         if $::postgresql_key {
28                 $ipaddr = assert_type(String[1], join(getfromhash($site::nodeinfo, 'ldap', 'ipHostNumber'), ","))
29
30                 @@concat::fragment { "onion::balance::instance::dsa-snippet::$name::$fqdn":
31                         target  => "/etc/dsa/postgresql-backup/sshkeys-sources",
32                         content  => @("EOF"),
33                                         ${::hostname} ${ipaddr} ${::postgresql_key}
34                                         | EOF
35                         tag     => "postgresql::server::backup-source-sshkey",
36                 }
37         }
38
39         @ferm::rule { "dsa-postgres-${postgresql::params::port}":
40                 description => 'Allow postgress access from backup host',
41                 domain      => '(ip ip6)',
42                 rule        => "&SERVICE_RANGE(tcp, ${postgresql::params::port}, ( @ipfilter(\$HOST_PGBACKUPHOST) ))",
43         }
44 }