]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blobdiff - modules/profile/manifests/postgresql/replication.pp
Refactor backup postgresql
[perso/Immae/Projets/Puppet.git] / modules / profile / manifests / postgresql / replication.pp
index 33b147fb74f2b7c22dedc5eab0193d229cf79c36..2fcb71cda258727834f6699c4aa576d291dc8e64 100644 (file)
@@ -1,7 +1,9 @@
 define profile::postgresql::replication (
-  Boolean $handle_role = false,
-  Boolean $add_self_role = false,
-  Boolean $handle_slot = false,
+  Boolean          $handle_role   = false,
+  Boolean          $handle_config = false,
+  Boolean          $add_self_role = false,
+  Boolean          $handle_slot   = false,
+  Optional[String] $target        = undef,
 ) {
   include "profile::postgresql::pam_ldap"
 
@@ -12,9 +14,11 @@ define profile::postgresql::replication (
     fail("Unable to find host for replication")
   }
 
-  ensure_resource("postgresql::server::config_entry", "wal_level", {
-    value => "logical",
-  })
+  if empty($target) {
+    $pg_version = undef
+  } else {
+    $pg_version = "10"
+  }
 
   $host_infos["ipHostNumber"].each |$ip| {
     $infos = split($ip, "/")
@@ -28,15 +32,23 @@ define profile::postgresql::replication (
     }
 
     postgresql::server::pg_hba_rule { "allow TCP access for replication to user $host_cn from $ipaddress/$mask":
-      type        => 'hostssl',
-      database    => 'replication',
-      user        => $host_cn,
-      address     => "$ipaddress/$mask",
-      auth_method => 'pam',
-      order       => "06-01",
+      type               => 'hostssl',
+      database           => 'replication',
+      user               => $host_cn,
+      address            => "$ipaddress/$mask",
+      auth_method        => 'pam',
+      order              => "06-01",
+      target             => $target,
+      postgresql_version => $pg_version,
     }
   }
 
+  if $handle_config {
+    ensure_resource("postgresql::server::config_entry", "wal_level", {
+      value => "logical",
+    })
+  }
+
   if $handle_role {
     postgresql::server::role { $host_cn:
       replication => true,