From c0edb244080f29970251618cf4452c3fafeb7677 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Sat, 28 Sep 2019 18:19:35 +0200 Subject: [PATCH] Move the backup of the pg instance of melartin to a more hiera and facter based setup --- data/common.yaml | 1 - data/nodes/melartin.debian.org.yaml | 1 + modules/postgres/manifests/backup_source.pp | 4 ++-- modules/roles/manifests/postgresql/server.pp | 22 ++++++++++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 modules/roles/manifests/postgresql/server.pp diff --git a/data/common.yaml b/data/common.yaml index 06f0d036d..e1e78c8b1 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -82,7 +82,6 @@ roles: - danzi.debian.org - fasolo.debian.org - lw07.debian.org - - melartin.debian.org - postgresql-manda-01.debian.org - sallinen.debian.org - seger.debian.org diff --git a/data/nodes/melartin.debian.org.yaml b/data/nodes/melartin.debian.org.yaml index 8a22ab94f..54b5365d5 100644 --- a/data/nodes/melartin.debian.org.yaml +++ b/data/nodes/melartin.debian.org.yaml @@ -1,3 +1,4 @@ classes: - roles::static_source - roles::mirrormaster + - roles::postgresql::server diff --git a/modules/postgres/manifests/backup_source.pp b/modules/postgres/manifests/backup_source.pp index 4941bfb55..663a6b490 100644 --- a/modules/postgres/manifests/backup_source.pp +++ b/modules/postgres/manifests/backup_source.pp @@ -17,7 +17,7 @@ class postgres::backup_source { ssh::keygen {'postgres': } - if $::hostname in [melartin, vittoria] { + if $::hostname in [vittoria] { postgres::backup_cluster { $::hostname: pg_version => '9.6', } @@ -63,7 +63,7 @@ class postgres::backup_source { } } - if $::hostname in [melartin, vittoria, godard, buxtehude, danzi, postgresql-manda-01] { + if $::hostname in [vittoria, godard, buxtehude, danzi, postgresql-manda-01] { postgres::backup_server::register_backup_clienthost { "backup-clienthost-${::fqdn}}": } } diff --git a/modules/roles/manifests/postgresql/server.pp b/modules/roles/manifests/postgresql/server.pp new file mode 100644 index 000000000..20c4c6cfc --- /dev/null +++ b/modules/roles/manifests/postgresql/server.pp @@ -0,0 +1,22 @@ +# +# postgresql server role +# +class roles::postgresql::server { + include postgres::backup_source + + $clusters = $facts['postgresql_clusters'] + $clusters.each |$cluster| { + # Do not backup clusters that are replication targets, + # like the dak mirror or snapshot secondaries + if ! $cluster['status']['recovery'] { + postgres::backup_cluster { $::hostname: + pg_version => $cluster['version'], + pg_cluster => $cluster['cluster'], + pg_port => $cluster['port'], + } + } + } + + postgres::backup_server::register_backup_clienthost { "backup-clienthost-${::fqdn}}": + } +} -- 2.20.1