]> WPIA git - infra.git/blobdiff - environments/production/manifests/postgres-primary.pp
add: make postgresql write archives
[infra.git] / environments / production / manifests / postgres-primary.pp
index e90109fd9610458fde006a763dc9e947255b49c1..c1f015aa7425f3af8522dd693916abf944f88ca1 100644 (file)
@@ -28,4 +28,42 @@ node postgres-primary {
     address     => "$gigi_ip/32",
     auth_method => 'md5',
   }
+
+  postgresql::server::db { 'quiz':
+    require  => Class['postgresql::server'],
+    user     => 'quiz',
+    password => postgresql_password('quiz', $passwords[postgres][quiz]),
+  }
+  postgresql::server::pg_hba_rule { 'allow quiz to access its database':
+    require  => Package['postgresql'],
+    description => "Open up PostgreSQL for access from quiz to its database",
+    type        => 'host',
+    database    => 'quiz',
+    user        => 'quiz',
+    address     => "${ips[quiz]}/32",
+    auth_method => 'md5',
+  }
+  postgresql::server::pg_hba_rule{'allow local replication by postgres':
+    #local   replication     postgres                ident
+    type        => 'local',
+    database    => 'replication',
+    user        => 'postgres',
+    auth_method => 'ident'
+  }
+  postgresql_conf{'archive_mode':
+    target => '/etc/postgresql/9.6/main/postgresql.conf',
+    value => 'on'
+  }
+  file{'/var/lib/postgresql/archive/':
+    ensure => 'directory',
+    owner => 'postgres'
+  } ->
+  postgresql_conf{'archive_command':
+    target => '/etc/postgresql/9.6/main/postgresql.conf',
+    value => 'test ! -f /var/lib/postgresql/archive/%f && cp %p /var/lib/postgresql/archive/%f'
+  }
+  postgresql_conf{'wal_level':
+    target => '/etc/postgresql/9.6/main/postgresql.conf',
+    value => 'replica'
+  }
 }