Akosiaris has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/80363


Change subject: Making the process of defining host backups easier
......................................................................

Making the process of defining host backups easier

Removed all the info about schedules, days, jobdefaults from
backup::host to make it easier to work with. Also created a (hopefully
even) distribution for machines on days of the week by using uniqueid
fact. Gone is the ugly sets hash and replaced with an array and an
optional pool argument which defaults to 'production'

Change-Id: Iacb3932a8727661d79d4987c825a6066b2c1c0d2
---
M manifests/backups.pp
M manifests/misc/install-server.pp
M manifests/role/backup.pp
M manifests/site.pp
4 files changed, 32 insertions(+), 35 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/63/80363/1

diff --git a/manifests/backups.pp b/manifests/backups.pp
index a5f0902..8c91bfd 100644
--- a/manifests/backups.pp
+++ b/manifests/backups.pp
@@ -1,9 +1,9 @@
-# backups (amanda)
+# backups (amanda transitioning to bacula)
 #
 
 # Transitioning to bacula stanzas
 
-class backup::host($sets) {
+class backup::host($sets, $pool='production') {
     include role::backup::config
 
     class { 'bacula::client':
@@ -13,7 +13,16 @@
         job_retention   => '6 months',
     }
 
-    create_resources(bacula::client::job, $sets)
+    # This will use uniqueid fact to distribute (hopefully evenly) machines on
+    # days of the week
+    $days = $role::backup::config::days
+    $day = inline_template('<%= @days[[@uniqueid].pack("H*").unpack("L")[0] % 
7] -%>')
+
+    $jobdefaults = "Monthly-1st-${day}-${pool}"
+
+    backup::host::sets { "${sets}":
+        jobdefaults => $jobdefaults,
+    }
 }
 
 class backup::mysqlhost($xtrabackup=true, $per_db=false, $innodb_only=false) {
@@ -24,7 +33,15 @@
     }
 }
 
-# Utility definition to deduplicate code
+# Utility definition used internally to deduplicate code
+define backup::host::sets($jobdefaults) {
+    bacula::client::job { "${name}-${jobdefaults}":
+        fileset     => $name,
+        jobdefaults => $jobdefaults,
+    }
+}
+
+# Utility definition used internally to deduplicate code
 define backup::schedule($pool) {
     bacula::director::schedule { "Monthly-1st-${name}":
         runs => [
diff --git a/manifests/misc/install-server.pp b/manifests/misc/install-server.pp
index 993ad9d..c38a2db 100644
--- a/manifests/misc/install-server.pp
+++ b/manifests/misc/install-server.pp
@@ -3,6 +3,13 @@
 class misc::install-server {
        system_role { "misc::install-server": description => "Install server" }
 
+    class { 'backup::host':
+        sets => [ 'srv-autoinstall',
+                  'srv-tftpboot',
+                  'srv-wikimedia',
+                ],
+    }
+
        class web-server {
                package { "lighttpd":
                        ensure => latest;
diff --git a/manifests/role/backup.pp b/manifests/role/backup.pp
index 9612236..b4d2bae 100644
--- a/manifests/role/backup.pp
+++ b/manifests/role/backup.pp
@@ -4,6 +4,7 @@
 class role::backup::config {
     $director = 'helium.eqiad.wmnet'
     $database = 'db1001.eqiad.wmnet'
+    $days = ['Sat', 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri']
 }
 
 class role::backup::director {
@@ -35,9 +36,7 @@
     # One schedule per day of the week.
     # Setting execution times so that it is unlikely jobs will run concurrently
     # with cron.{hourly,daily,monthly} or other cronscripts
-    $days = ['Sat', 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri']
-
-    backup::schedule { $days:
+    backup::schedule { $role::backup::config::days:
         pool    => 'production',
     }
 
diff --git a/manifests/site.pp b/manifests/site.pp
index 04128ee..c49b214 100644
--- a/manifests/site.pp
+++ b/manifests/site.pp
@@ -258,25 +258,6 @@
     class { 'misc::haproxy':
         config_file =>  'puppet:///files/puppet/haproxy.cfg',
     }
-    # Backup sets
-    $backupsets = {
-        'srv-autoinstall' => {
-            fileset     => 'srv-autoinstall',
-            jobdefaults => 'Monthly-1st-Tue-production',
-        },
-        'srv-tftpboot' => {
-            fileset     => 'srv-tftpboot',
-            jobdefaults => 'Monthly-1st-Wed-production',
-        },
-        'srv-wikimedia' => {
-            fileset     => 'srv-wikimedia',
-            jobdefaults => 'Monthly-1st-Thu-production',
-        },
-    }
-
-    class { 'backup::host':
-        sets => $backupsets,
-    }
 }
 
 node "caesium.wikimedia.org" {
@@ -1050,16 +1031,9 @@
         role::backup::director,
         role::backup::storage
 
-    # Backup sets
-    $backupsets = {
-        'roothome'  => {
-            fileset     => 'roothome',
-            jobdefaults => 'Monthly-1st-Mon-production',
-        },
-    }
-
+    # TODO: Remove this at some point (after 2013-10-31). It is here for 
testing reasons
     class { 'backup::host':
-        sets => $backupsets,
+        sets => [ 'roothome',],
     }
 }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/80363
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iacb3932a8727661d79d4987c825a6066b2c1c0d2
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Akosiaris <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to