]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/commitdiff
Fix dumps when postgres port is present
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 28 Jun 2018 11:15:01 +0000 (13:15 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 28 Jun 2018 11:20:11 +0000 (13:20 +0200)
modules/profile/manifests/postgresql/backup_dump.pp
modules/profile/manifests/postgresql/backup_replication.pp

index 10e349a560d0b9126a75192eca2d2daa1af05e7c..53fb20ee0b3b2336ac7e3fd241252ceb09f44833 100644 (file)
@@ -1,6 +1,7 @@
 define profile::postgresql::backup_dump (
-  String $pg_user  = "postgres",
-  String $pg_group = "postgres",
+  String                             $pg_user  = "postgres",
+  String                             $pg_group = "postgres",
+  Optional[Variant[String, Integer]] $pg_port  = undef,
 ) {
   $base_path        = $title
   $pg_path          = "$base_path/postgresql"
@@ -23,12 +24,18 @@ define profile::postgresql::backup_dump (
     require => File[$base_path],
   }
 
+  if $pg_port and !empty($pg_port) {
+    $pg_port_arg = " -p $pg_port"
+  } else {
+    $pg_port_arg = ""
+  }
+
   cron::job::multiple { "backup_psql_$pg_host":
     ensure  => "present",
     require => [File[$pg_backup_path], File[$pg_path]],
     jobs    => [
       {
-        command     => "/usr/bin/pg_dumpall -h $pg_path -f $pg_backup_path/\$(date -Iseconds).sql",
+        command     => "/usr/bin/pg_dumpall -h $pg_path$pg_port_arg -f $pg_backup_path/\$(date -Iseconds).sql",
         user        => $pg_user,
         hour        => "22,4,10,16",
         minute      => 0,
index a4edb8f2a9c526737aee8605fab48ab76d6ec4a3..1526123b2b8d854ff173401e88afb26e7cf50617 100644 (file)
@@ -61,6 +61,8 @@ define profile::postgresql::backup_replication (
       target => "$pg_path/pg_hba.conf",
     }
   } else {
+    $pg_listen_port = undef
+
     concat::fragment { "$pg_path/postgresql.conf listen":
       target  => "$pg_path/postgresql.conf",
       content => "listen_addresses = ''\n",
@@ -130,6 +132,8 @@ define profile::postgresql::backup_replication (
   }
 
   # Dumps
-  profile::postgresql::backup_dump { "$base_path/$pg_backup_host": }
+  profile::postgresql::backup_dump { "$base_path/$pg_backup_host":
+    pg_port => $pg_listen_port,
+  }
 
 }