1 define profile::postgresql::replication (
2 Boolean $handle_role = false,
3 Boolean $handle_config = false,
4 Boolean $add_self_role = false,
5 Boolean $handle_slot = false,
6 Optional[String] $target = undef,
8 include "profile::postgresql::pam_ldap"
11 $host_infos = find_host($facts["ldapvar"]["other"], $host_cn)
13 if empty($host_infos) {
14 fail("Unable to find host for replication")
23 $host_infos["ipHostNumber"].each |$ip| {
24 $infos = split($ip, "/")
25 $ipaddress = $infos[0]
26 if (length($infos) == 1 and $ipaddress =~ /:/) {
28 } elsif (length($infos) == 1) {
34 postgresql::server::pg_hba_rule { "allow TCP access for replication to user $host_cn from $ipaddress/$mask":
36 database => 'replication',
38 address => "$ipaddress/$mask",
42 postgresql_version => $pg_version,
47 ensure_resource("postgresql::server::config_entry", "wal_level", {
53 postgresql::server::role { $host_cn:
55 require => Service["postgresql"],
59 $ldap_cn = lookup("base_installation::ldap_cn")
61 # Needed to be replicated to the backup and be able to recover later
62 ensure_resource("postgresql::server::role", $ldap_cn, {
64 require => Service["postgresql"],
70 postgresql_replication_slot { regsubst($host_cn, '-', "_", "G"):
72 require => Service["postgresql"],