Move the backup of the pg instance of melartin to a more hiera and facter based setup
authorPeter Palfrader <peter@palfrader.org>
Sat, 28 Sep 2019 16:19:35 +0000 (18:19 +0200)
committerPeter Palfrader <peter@palfrader.org>
Sat, 28 Sep 2019 16:19:35 +0000 (18:19 +0200)
data/common.yaml
data/nodes/melartin.debian.org.yaml
modules/postgres/manifests/backup_source.pp
modules/roles/manifests/postgresql/server.pp [new file with mode: 0644]

index 06f0d03..e1e78c8 100644 (file)
@@ -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
index 8a22ab9..54b5365 100644 (file)
@@ -1,3 +1,4 @@
 classes:
   - roles::static_source
   - roles::mirrormaster
+  - roles::postgresql::server
index 4941bfb..663a6b4 100644 (file)
@@ -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 (file)
index 0000000..20c4c6c
--- /dev/null
@@ -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}}":
+  }
+}