migrate away from old postgres_backup_server role
authorPeter Palfrader <peter@palfrader.org>
Sat, 28 Sep 2019 17:53:19 +0000 (19:53 +0200)
committerPeter Palfrader <peter@palfrader.org>
Sat, 28 Sep 2019 17:53:19 +0000 (19:53 +0200)
data/common.yaml
data/nodes/backuphost.debian.org.yaml [new file with mode: 0644]
data/nodes/storace.debian.org.yaml
modules/ferm/manifests/per_host.pp
modules/ferm/templates/defs.conf.erb
modules/postgres/manifests/backup_cluster.pp
modules/roles/manifests/init.pp

index 73e3c95..3e45e09 100644 (file)
@@ -71,10 +71,6 @@ apt::sources::debian::location: 'https://deb.debian.org/debian/'
 # all of these should be retired in favour of including the class role
 # with the host. weasel, 2019-09
 roles:
-  postgres_backup_server:
-    # XXX - used by ferm templates/defs.conf.erb
-    - backuphost.debian.org
-    - storace.debian.org
   postgresql_server:
     # these use pg-receive-file-from-backup which is defined in the
     # postgres::backup_source class.  This should be
diff --git a/data/nodes/backuphost.debian.org.yaml b/data/nodes/backuphost.debian.org.yaml
new file mode 100644 (file)
index 0000000..92b2b62
--- /dev/null
@@ -0,0 +1,3 @@
+---
+classes:
+  - postgres::backup_server
index 2c5eac0..ca972f8 100644 (file)
@@ -1,4 +1,5 @@
 ---
 classes:
   - bacula::storage
+  - postgres::backup_server
   - profile::ipsec::fasolo_storace
index 4a0fe13..7a15b86 100644 (file)
@@ -149,7 +149,6 @@ class ferm::per_host {
         rule        => @("EOF"/$)
           &SERVICE_RANGE(tcp, 5440, (
             ${ join(getfromhash($deprecated::allnodeinfo, 'sor.debian.org', 'ipHostNumber'), " ") }
-            \$HOST_PGBACKUPHOST
           ))
           | EOF
       }
index 9265849..348d08b 100644 (file)
 }
 
 <%
-  rolehost={}
   allnodeinfo = scope.lookupvar('deprecated::allnodeinfo')
-  roles = scope.lookupvar('deprecated::roles')
-
-  %w{postgres_backup_server}.each do |role|
-    rolehost[role] = []
-    roles[role].each do |node|
-        next unless allnodeinfo.has_key?(node) and allnodeinfo[node].has_key?('ipHostNumber')
-        rolehost[role] << allnodeinfo[node]['ipHostNumber']
-    end
-    rolehost[role].flatten!.sort.uniq
-  end
-
   dbs = []
   allnodeinfo.keys.sort.each do |node|
       next unless allnodeinfo[node].has_key?('ipHostNumber')
@@ -41,9 +29,6 @@
   dbs.flatten!
 %>
 
-@def $HOST_PGBACKUPHOST = (<%= rolehost['postgres_backup_server'].uniq.join(' ') %>);
-
-
 <%
 def getfastlyranges()
     begin
index f1cc44a..10a4346 100644 (file)
@@ -7,7 +7,6 @@ define postgres::backup_cluster(
   String $db_backup_role_password = hkdf('/etc/puppet/secret', "postgresql-${::hostname}-${$pg_cluster}-${pg_port}-backup_role}"),
   Boolean $do_role = false,
   Boolean $do_hba = false,
-  $backup_servers = getfromhash($deprecated::roles, 'postgres_backup_server'),
 ) {
   $datadir = "/var/lib/postgresql/${pg_version}/${pg_cluster}"
   file { "${datadir}/.nobackup":
@@ -17,7 +16,6 @@ define postgres::backup_cluster(
   ## XXX - get these from the roles and ldap
   # backuphost, storace
   $backup_servers_addrs = ['5.153.231.12/32', '93.94.130.161/32', '2001:41c8:1000:21::21:12/128', '2a02:158:380:280::161/128']
-  $backup_servers_addrs_joined = join($backup_servers_addrs, ' ')
 
   if $do_role {
     postgresql::server::role { $db_backup_role:
@@ -37,10 +35,10 @@ define postgres::backup_cluster(
       }
     }
   }
-  ferm::rule { "dsa-postgres-${pg_port}":
+  ferm::rule::simple { "dsa-postgres-backup-${pg_port}":
     description => 'Allow postgress access from backup host',
-    domain      => '(ip ip6)',
-    rule        => "&SERVICE_RANGE(tcp, ${pg_port}, ( @ipfilter((${backup_servers_addrs_joined})) ))",
+    port        => $pg_port,
+    saddr       => $backup_servers_addrs,
   }
 
   postgres::backup_server::register_backup_cluster { "backup-role-${::fqdn}}-${pg_port}":
index 9e5e649..6122e78 100644 (file)
@@ -1,10 +1,6 @@
 # = Class: roles
 #
 class roles {
-  if has_role('postgres_backup_server') {
-    include postgres::backup_server
-  }
-
   if has_role('postgresql_server') {
     include postgres::backup_source
   }