Allow us to gradually move a server with multiple clusters to move to managed hba
authorPeter Palfrader <peter@palfrader.org>
Sun, 29 Sep 2019 14:30:28 +0000 (16:30 +0200)
committerPeter Palfrader <peter@palfrader.org>
Sun, 29 Sep 2019 14:30:28 +0000 (16:30 +0200)
modules/roles/manifests/postgresql/server.pp

index 99a8237..fd8f916 100644 (file)
@@ -3,18 +3,24 @@
 #
 # @param manage_clusters_hba manage clusters' pg_hba.conf using postgres::cluster.  Eventually should should be true for every host and we can drop the param
 class roles::postgresql::server(
-  Boolean $manage_clusters_hba = false,
+  Variant[Boolean,Array[Integer]] $manage_clusters_hba = false,
 ) {
   $clusters = $facts['postgresql_clusters']
   $clusters.each |$cluster| {
     $version      = $cluster['version']
     $cluster_name = $cluster['cluster']
     $port         = $cluster['port']
+
+    if $manage_clusters_hba =~ Boolean {
+      $hba = $manage_clusters_hba
+    } else {
+      $hba = $port in $manage_clusters_hba
+    }
     postgres::cluster { "${version}::${cluster_name}":
       pg_version => $version,
       pg_cluster => $cluster_name,
       pg_port    => $port,
-      manage_hba => $manage_clusters_hba,
+      manage_hba => $hba,
     }
   }
 }