1 define profile::postgresql::replication (
2 Boolean $handle_role = false,
3 Boolean $add_self_role = false,
4 Boolean $handle_slot = false,
6 include "profile::postgresql::pam_ldap"
9 $host_infos = find_host($facts["ldapvar"]["other"], $host_cn)
11 if empty($host_infos) {
12 fail("Unable to find host for replication")
15 ensure_resource("postgresql::server::config_entry", "wal_level", {
19 $host_infos["ipHostNumber"].each |$ip| {
20 $infos = split($ip, "/")
21 $ipaddress = $infos[0]
22 if (length($infos) == 1 and $ipaddress =~ /:/) {
24 } elsif (length($infos) == 1) {
30 postgresql::server::pg_hba_rule { "allow TCP access for replication to user $host_cn from $ipaddress/$mask":
32 database => 'replication',
34 address => "$ipaddress/$mask",
41 postgresql::server::role { $host_cn:
46 $ldap_cn = lookup("base_installation::ldap_cn")
48 # Needed to be replicated to the backup and be able to recover later
49 ensure_resource("postgresql::server::role", $ldap_cn, {
56 postgresql_replication_slot { regsubst($host_cn, '-', "_", "G"):