1 node postgres-primary {
2 include container::contained
3 include container::no_ssh
5 exec { 'backup installed':
6 before => Package['postgresql'],
7 notify => Exec['backup permissions corrected'],
8 command => '! [ -f /var/lib/postgresql/9.6/main/PG_VERSION ] && mkdir -p /var/lib/postgresql/9.6/main && tar xzf /var/lib/postgresql/pg_base.tar.gz -C /var/lib/postgresql/9.6/main',
9 onlyif => '[ -f /var/lib/postgresql/pg_base.tar.gz ]',
12 package{ 'postgresql':
13 ensure => 'installed',
14 install_options => ['--no-install-recommends'],
16 class { 'postgresql::globals':
19 class { 'postgresql::server':
20 listen_addresses => '*',
22 exec { 'backup permissions corrected':
23 require => Class['postgresql::server::install'],
24 before => Class['postgresql::server::initdb'],
25 command => 'chown -R postgres:postgres /var/lib/postgresql && rm /var/lib/postgresql/pg_base.tar.gz',
26 onlyif => '[ -f /var/lib/postgresql/pg_base.tar.gz ]',
27 refreshonly => 'true',
30 postgresql::server::db { 'gigi':
31 require => Package['postgresql'],
33 password => postgresql_password('gigi', $passwords[postgres][gigi]),
35 $gigi_ip = $ips[gigi];
36 postgresql::server::pg_hba_rule { 'allow gigi to access its database':
37 require => Package['postgresql'],
38 description => "Open up PostgreSQL for access from gigi to its database",
42 address => "$gigi_ip/32",
46 postgresql::server::db { 'quiz':
47 require => Exec['backup installed'],
49 password => postgresql_password('quiz', $passwords[postgres][quiz]),
51 postgresql::server::pg_hba_rule { 'allow quiz to access its database':
52 require => Package['postgresql'],
53 description => "Open up PostgreSQL for access from quiz to its database",
57 address => "${ips[quiz]}/32",
60 postgresql::server::pg_hba_rule{'allow local replication by postgres':
61 #local replication postgres ident
63 database => 'replication',
65 auth_method => 'ident'
67 postgresql_conf{'archive_mode':
68 target => '/etc/postgresql/9.6/main/postgresql.conf',
71 file{'/var/lib/postgresql/archive/':
72 require => Exec['backup permissions corrected'],
73 ensure => 'directory',
76 postgresql_conf{'archive_command':
77 target => '/etc/postgresql/9.6/main/postgresql.conf',
78 value => 'test ! -f /var/lib/postgresql/archive/%f && cp %p /var/lib/postgresql/archive/%f'
80 postgresql_conf{'wal_level':
81 target => '/etc/postgresql/9.6/main/postgresql.conf',
84 postgresql_conf{'max_wal_senders':
85 target => '/etc/postgresql/9.6/main/postgresql.conf',