]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/commitdiff
Listen to port depending on host variable
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Wed, 27 Jun 2018 10:37:18 +0000 (12:37 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Wed, 27 Jun 2018 10:54:33 +0000 (12:54 +0200)
modules/role/manifests/backup/postgresql.pp
modules/role/templates/backup/postgresql.conf.erb

index 9e1c9f706d1c66521d640fe8850b71ff8b938b24..aef177b776a64b1bf30ee75639e015ba72f611ba 100644 (file)
@@ -121,6 +121,12 @@ class role::backup::postgresql inherits role::backup {
     } else {
       $pg_backup_host = $host["vars"]["real_hostname"][0]
     }
+    if has_key($host["vars"], "postgresql_backup_port") {
+      $pg_listen_port = $host["vars"]["postgresql_backup_port"][0]
+    } else {
+      $pg_listen_port = undef
+    }
+
     $pg_path = "$mountpoint/$pg_backup_host/postgresql"
     $pg_backup_path = "$mountpoint/$pg_backup_host/postgresql_backup"
     $pg_host = "$pg_backup_host"
@@ -152,10 +158,16 @@ class role::backup::postgresql inherits role::backup {
     }
 
     if !empty($ldap_filter) and ($pg_infos["pgbouncer"]) {
+      if empty($pg_listen_port) {
+        $pg_listen_port_key = ""
+      } else {
+        $pg_listen_port_key = "port=$pg_listen_port"
+      }
+
       concat::fragment { "pgbouncer_$pg_backup_host":
         target  => "/etc/pgbouncer/pgbouncer.ini",
         order   => 02,
-        content => "${pg_infos[pgbouncer_dbname]} = host=$mountpoint/$pg_backup_host/postgresql user=${pg_infos[dbuser]} dbname=${pg_infos[dbname]}",
+        content => "${pg_infos[pgbouncer_dbname]} = host=$mountpoint/$pg_backup_host/postgresql $pg_listen_port_key user=${pg_infos[dbuser]} dbname=${pg_infos[dbname]}",
       }
 
       postgresql::server::pg_hba_rule { "$pg_backup_host - local access as ${pg_infos[dbuser]} user":
index 860089b7007cdb27a0263c64ae88d20f59ff86fb..c4d223e8bace6bef6c362b1af2ea439e4350a26c 100644 (file)
@@ -1,5 +1,10 @@
+<%- if !@pg_listen_port.nil? -%>
+listen_addresses= '*'
+port = <%= @pg_listen_port %>
+ssl = on
+<%- else -%>
 listen_addresses= ''
+<%- end %>
 unix_socket_directories = '<%= @pg_path %>'
 data_directory = '<%= @pg_path %>'
 wal_level = logical
-