X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Froles%2Fmanifests%2Fsnapshot_db.pp;h=c620c8793feb45577e20d8c5eb990fb7a47d31ce;hb=e7fec35f88f5958af2e23a677912f6360e4c66bb;hp=a14df0203141025a4752f6d6c317615db6c083af;hpb=12c290a9438b5becc2e2a48f54083295ddee32f8;p=mirror%2Fdsa-puppet.git diff --git a/modules/roles/manifests/snapshot_db.pp b/modules/roles/manifests/snapshot_db.pp index a14df0203..c620c8793 100644 --- a/modules/roles/manifests/snapshot_db.pp +++ b/modules/roles/manifests/snapshot_db.pp @@ -1,10 +1,16 @@ -# 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') @@ -40,7 +46,19 @@ class roles::snapshot_db ( user => 'guest', address => $guest_addresses, method => 'trust', + order => '20', } - + 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, + } + } }