roles::postgresql::server::manage_clusters_hba: true
roles::snapshot_db::db_port: 5442
roles::snapshot_db::guest_addresses: ['185.17.185.176/28', '2001:1af8:4020:b030::/64'] # leaseweb
+roles::snapshot_db::upstream_db_server: sallinen.debian.org
+roles::snapshot_db::upstream_db_port: 5473
-# db server providing (secondary) snapshot databases
+# db server providing snapshot databases
#
# @param db_port port of the snapshot cluster
# @param guest_addresses addresses to allow for the guest account
+# @param upstream_db_server if this node is a replica, name of the upstream db server
+# @param upstream_db_port if this node is a replica, port of the upstream db server
+# @param upstream_db_role if this node is a replica, replication role on the upstream db server
class roles::snapshot_db (
Integer $db_port,
Array[Stdlib::IP::Address] $guest_addresses = ['127.0.0.1', '::1'],
+ Optional[String] $upstream_db_server = undef,
+ Optional[Integer] $upstream_db_port = undef,
+ String $upstream_db_role = "repuser-${::hostname}",
) {
$now = Timestamp()
$date = $now.strftime('%F')
user => 'guest',
address => $guest_addresses,
method => 'trust',
+ order => '30',
}
-
+ if $upstream_db_server {
+ if !$upstream_db_port {
+ fail ('Also need a port if we have a upstream_db_server')
+ }
+ @@postgres::cluster::hba_entry { "snapshot-replica-to-${::fqdn}":
+ tag => "postgres::cluster::${upstream_db_port}::hba::${upstream_db_server}",
+ pg_port => $upstream_db_port,
+ database => 'replication',
+ user => $upstream_db_role,
+ address => $base::public_addresses,
+ }
+ }
}