X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fpostgres%2Fmanifests%2Fbackup_cluster.pp;h=dcbf28f673fe02fe869622474bd2e5da41e6bbc5;hb=6680306de7b2f9911a4da12b8484d3431056ea53;hp=bd6ef0916d861004bd118ba5a54a5c94aa95df2b;hpb=700ff9b34f1c3182776b0fc8c0e8e77265194ede;p=mirror%2Fdsa-puppet.git diff --git a/modules/postgres/manifests/backup_cluster.pp b/modules/postgres/manifests/backup_cluster.pp index bd6ef0916..dcbf28f67 100644 --- a/modules/postgres/manifests/backup_cluster.pp +++ b/modules/postgres/manifests/backup_cluster.pp @@ -1,12 +1,26 @@ # Backup this cluster # +# This define causes the cluster to be registered on the backupservers. +# +# Furthermore, if this cluster is managed with postgresql::server and +# do_role and do_hba are set, we create the role and modify the pg_hba.conf file. +# +# Since postgresql::server only supports a single cluster per host, we are moving +# towards our own postgres::cluster, and this define also exports a hba rule for +# those (regardless of the do_hba setting). If the cluster is managed with +# postgres::cluster and has its manage_hba option set, this will then cause the +# backup hosts to be allowed to replacate. +# +# Regarless of how the cluster is managed, firewall rules are set up to allow +# access from the backup hosts. +# # @param pg_version pg version of the cluster # @param pg_cluster cluster name # @param pg_port port of the postgres cluster # @param db_backup_role replication role username # @param db_backup_role_password password of the replication role # @param do_role create the role (requires setup with postgresql::server) -# @param do_hba update pg_hba (requires setup with postgresql::server) +# @param do_hba update pg_hba (requires setup with postgresql::server) define postgres::backup_cluster( String $pg_version, String $pg_cluster = 'main', @@ -16,6 +30,8 @@ define postgres::backup_cluster( Boolean $do_role = false, Boolean $do_hba = false, ) { + include postgres::backup_source + $datadir = "/var/lib/postgresql/${pg_version}/${pg_cluster}" file { "${datadir}/.nobackup": content => '' @@ -44,18 +60,14 @@ define postgres::backup_cluster( } } - # Send connections to the port to the pg-backup chain - # there, the register_backup_clienthost class will have - # realized the exported allows from the backup servers. - # - # Any non-matching traffic will fall through and it can - # be allowed elsewhere - ferm::rule::simple { "dsa-postgres-backup-${pg_port}": - description => 'Check for postgres access from backup host', - port => $pg_port, - target => 'pg-backup', + postgres::cluster::hba_entry { "backup-replication::${pg_version}::${pg_cluster}": + pg_version => $pg_version, + pg_cluster => $pg_cluster, + pg_port => $pg_port, + database => 'replication', + user => $db_backup_role, + address => $backup_servers_addrs, } - postgres::backup_server::register_backup_cluster { "backup-role-${::fqdn}}-${pg_port}": pg_port => $pg_port, pg_role => $db_backup_role,