firwalling for pg basebackup
authorPeter Palfrader <peter@palfrader.org>
Sat, 28 Sep 2019 20:18:02 +0000 (22:18 +0200)
committerPeter Palfrader <peter@palfrader.org>
Sat, 28 Sep 2019 20:18:02 +0000 (22:18 +0200)
modules/postgres/manifests/backup_cluster.pp
modules/postgres/manifests/backup_server.pp
modules/postgres/manifests/backup_server/register_backup_clienthost.pp

index 102f264..bd6ef09 100644 (file)
@@ -43,10 +43,17 @@ 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 => 'Allow postgress access from backup host',
+    description => 'Check for postgres access from backup host',
     port        => $pg_port,
-    saddr       => $backup_servers_addrs,
+    target      => 'pg-backup',
   }
 
   postgres::backup_server::register_backup_cluster { "backup-role-${::fqdn}}-${pg_port}":
index bf8efa0..34a68b6 100644 (file)
@@ -98,4 +98,15 @@ class postgres::backup_server {
     mode  => '0400'
   }
   Concat::Fragment <<| tag == $postgres::backup_server::globals::tag_source_pgpassline |>>
+
+  ####
+  # Let us connect to the clusters we want
+  #
+  # We export this, and the backup clients collect it
+  @@ferm::rule::simple { "pg-backup_server::${::fqdn}":
+    tag         => 'postgres::backup_server::to-client',
+    description => 'Allow access access from backup host',
+    chain       => 'pg-backup',
+    saddr       => $base::public_addresses,
+  }
 }
index 5dff845..8c288dd 100644 (file)
@@ -23,4 +23,6 @@ define postgres::backup_server::register_backup_clienthost (
     from        => $base::public_addresses,
     collect_tag => $postgres::backup_server::globals::tag_source_sshkey,
   }
+
+  Ferm::Rule::Simple <<| tag == 'postgres::backup_server::to-client' |>>
 }