]> git.donarmstrong.com Git - dsa-puppet.git/commitdiff
Add per client pools, storages, devices, mediatypes
authorPeter Palfrader <peter@palfrader.org>
Fri, 24 Aug 2012 13:52:55 +0000 (13:52 +0000)
committerPeter Palfrader <peter@palfrader.org>
Fri, 24 Aug 2012 13:52:55 +0000 (13:52 +0000)
modules/bacula/manifests/client.pp
modules/bacula/manifests/node.pp
modules/bacula/manifests/storage-per-node.pp [new file with mode: 0644]
modules/bacula/manifests/storage.pp
modules/bacula/templates/bacula-dir.conf.erb
modules/bacula/templates/bacula-sd.conf.erb
modules/bacula/templates/per-client.conf.erb
modules/bacula/templates/storage-per-client.conf.erb [new file with mode: 0644]

index e7506bffb158ef43d9906b76c03451b74b7c4c5c..a718c812333fbb225a61e0e24ec7f061c6782a8a 100644 (file)
@@ -1,4 +1,5 @@
 class bacula::client inherits bacula {
+       @@bacula::storage-per-node { $::fqdn: }
 
        package { ['bacula-fd']:
                ensure => installed
index c96e69df918a17ae85cb1214251deeed4580a059..5552627ae90d0ec9c97932efde8094e22ddcad94 100644 (file)
@@ -2,6 +2,13 @@ define bacula::node() {
 
        include bacula
 
+       $bacula_pool_name         = $bacula::bacula_pool_name
+       $bacula_filestor_name     = $bacula::bacula_filestor_name
+       $bacula_filestor_device   = $bacula::bacula_filestor_device
+       $bacula_storage_address   = $bacula::bacula_storage_address
+       $bacula_storage_port      = $bacula::bacula_storage_port
+       $bacula_storage_secret    = $bacula::bacula_storage_secret
+
        $bacula_client_port   = $bacula::bacula_client_port
        $bacula_ca_path       = $bacula::bacula_ca_path
        $bacula_ssl_client_cert = $bacula::bacula_ssl_client_cert
diff --git a/modules/bacula/manifests/storage-per-node.pp b/modules/bacula/manifests/storage-per-node.pp
new file mode 100644 (file)
index 0000000..e8926eb
--- /dev/null
@@ -0,0 +1,27 @@
+define bacula::storage-per-node() {
+
+       include bacula
+
+       $bacula_filestor_device = $bacula::bacula_filestor_device
+       $bacula_filestor_name   = $bacula::bacula_filestor_name
+       $bacula_backup_path     = $bacula::bacula_backup_path
+
+       $bacula_client_name   = "${name}-fd"
+       $client               = $name
+
+       file {
+               "/etc/bacula/storage-conf.d/${name}.conf":
+                       content => template('bacula/storage-per-client.conf.erb'),
+                       mode    => '0440',
+                       group   => bacula,
+                       notify  => Exec['bacula-sd reload'],
+                       ;
+               "${bacula_backup_path}/${name}":
+                       ensure  => directory,
+                       mode    => '0755',
+                       owner   => bacula,
+                       group   => bacula,
+                       ;
+       }
+}
+
index e6738672d67f902a6d4798539fb3bbb0498bf00b..7b1c1a8341a79ced3333f645a5fb1095758b8dde 100644 (file)
@@ -9,6 +9,16 @@ class bacula::storage inherits bacula {
                enable    => true,
                hasstatus => true,
        }
+
+       # should wait on -sd to finish current backups, then restart
+       # since it does not support reload and restarting kills running
+       # jobs
+       exec { 'bacula-sd reload':
+               path        => '/usr/bin:/usr/sbin:/bin:/sbin',
+               command     => 'true',
+               refreshonly => true,
+       }
+
        file { '/etc/bacula/bacula-sd.conf':
                content => template('bacula/bacula-sd.conf.erb'),
                mode    => '0640',
@@ -16,6 +26,17 @@ class bacula::storage inherits bacula {
                notify  => Service['bacula-sd']
        }
 
+       file { '/etc/bacula/storage-conf.d':
+               ensure  => directory,
+               mode    => '0755',
+               group   => bacula,
+               purge   => true,
+               force   => true,
+               recurse => true,
+               source  => 'puppet:///files/empty/',
+               notify  => Exec['bacula-sd reload']
+       }
+
        @ferm::rule { 'dsa-bacula-sd-v4':
                domain      => '(ip)',
                description => 'Allow bacula-sd access from director and clients',
@@ -29,4 +50,14 @@ class bacula::storage inherits bacula {
                rule        => 'proto tcp mod state state (NEW) dport (bacula-sd) @subchain \'bacula-sd\' { saddr ($HOST_DEBIAN_V6) ACCEPT; }',
                notarule    => true,
        }
+
+       file { '/etc/bacula/storage-conf.d/empty.conf':
+               content => '',
+               mode    => '0440',
+               group   => bacula,
+               notify  => Exec['bacula-sd reload']
+       }
+
+       Bacula::Storage-per-Node<<| |>>
+
 }
index 4a4c52d852e1c7ba255e0e747aabf4cba71361a6..fe2d5ee2a4e9ea35b57ace16d068adb9b4e9bb34 100644 (file)
@@ -136,27 +136,6 @@ Messages {
   append = "/var/lib/bacula/log" = all, !skipped
 }
 
-########################################################################
-# Storage config                                                       #
-########################################################################
-
-Storage {
-  Name = <%= bacula_filestor_name %>
-  Address = <%= bacula_storage_address %>
-  SDPort = <%= bacula_storage_port %>
-  Password = "<%= bacula_storage_secret %>"
-  Device = <%= bacula_filestor_device %>
-  Media Type = <%= bacula_filestor_name %>
-  Maximum Concurrent Jobs = 10
-
-  TLS Enable = yes
-  TLS Require = yes
-  TLS CA Certificate File = "<%= bacula_ca_path %>"
-  # This is a client certificate, used by the director to connect to the storage daemon
-  TLS Certificate = "<%= bacula_ssl_client_cert %>"
-  TLS Key = "<%= bacula_ssl_client_key %>"
-}
-
 ########################################################################
 # Console, limited                                                     #
 ########################################################################
@@ -176,9 +155,6 @@ JobDefs {
   FileSet = "Standard Set"
   Schedule = "WeeklyCycle"
   Messages = Standard
-  Pool = <%=bacula_pool_name%>
-  Differential Backup Pool = <%=bacula_pool_name%>diff
-  Incremental Backup Pool = <%=bacula_pool_name%>inc
   Max Full Interval = 1 month
   Priority = 10
   Write Bootstrap = "/var/lib/bacula/%c.bsr"
@@ -193,57 +169,13 @@ JobDefs {
 Job {
   Name = "RestoreFiles"
   Type = Restore
-  Client = draghi.debian.org-fd
+  Client = <%=bacula_director_address%>-fd
   FileSet = "Standard Set"
-  Pool = <%=bacula_pool_name%>
+  Pool = full-<%=bacula_pool_name%>-<%=bacula_director_address%>
   Messages = Standard
   Where = /var/tmp/bacula-restores
 }
 
-########################################################################
-# Pool definition                                                      #
-########################################################################
-Pool {
-  Name = <%= bacula_pool_name %>
-  Pool Type = Backup
-  Storage = <%=bacula_filestor_name%>
-  Recycle = no
-  AutoPrune = yes
-  Volume Retention = 1 year
-  Label Format = "<%= bacula_pool_name %>.${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}_${Hour:p/2/0/r}:${Minute:p/2/0/r}"
-  Volume Use Duration = 23h
-  #Maximum Volume Jobs = 1
-  Maximum Volume Bytes = 50G
-  Action On Purge = Truncate
-}
-
-Pool {
-  Name = <%= bacula_pool_name %>diff
-  Pool Type = Backup
-  Storage = <%=bacula_filestor_name%>
-  Recycle = no
-  AutoPrune = yes
-  Volume Retention = 1 year
-  Label Format = "<%= bacula_pool_name %>diff.${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}_${Hour:p/2/0/r}:${Minute:p/2/0/r}"
-  Volume Use Duration = 23h
-  #Maximum Volume Jobs = 1
-  Maximum Volume Bytes = 50G
-  Action On Purge = Truncate
-}
-
-Pool {
-  Name = <%= bacula_pool_name %>inc
-  Pool Type = Backup
-  Storage = <%=bacula_filestor_name%>
-  Recycle = no
-  AutoPrune = yes
-  Volume Retention = 1 year
-  Label Format = "<%= bacula_pool_name %>inc.${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}_${Hour:p/2/0/r}:${Minute:p/2/0/r}"
-  Volume Use Duration = 23h
-  #Maximum Volume Jobs = 1
-  Maximum Volume Bytes = 50G
-  Action On Purge = Truncate
-}
 
 # Scratch pool definition
 Pool {
index 11e5b084b5b2a46d5a5e1d72235f4dd720877f09..c6d99732b992a3980351d8e37bc5e2f956b14ac8 100644 (file)
@@ -62,3 +62,4 @@ Messages {
   Name = Standard
   director = <%= bacula_director_name %> = all
 }
+@|"sh -c 'for f in /etc/bacula/storage-conf.d/*.conf ; do echo @${f} ; done'"
index 9be2f42a97535fd7a324fdc3fd538edb064fc42b..5451b460aa4e262d41387f4254ec5cdc444b9659 100644 (file)
@@ -9,6 +9,10 @@ Job {
   JobDefs = "Standardbackup"
   Client = <%= bacula_client_name %>
 
+  Pool = "poolfull-<%= bacula_pool_name %>-<%= client %>"
+  Differential Backup Pool = "pooldiff-<%= bacula_pool_name %>-<%= client %>"
+  Incremental Backup Pool = "poolinc-<%= bacula_pool_name %>-<%= client %>"
+
   #Rerun Failed Levels = yes
   Reschedule On Error = yes
   Reschedule Interval = 4 hours
@@ -38,3 +42,69 @@ Client {
   TLS Certificate = "<%= bacula_ssl_client_cert %>"
   TLS Key = "<%= bacula_ssl_client_key %>"
 }
+
+########################################################################
+# Storage config                                                       #
+########################################################################
+
+Storage {
+  Name = "<%= bacula_filestor_name %>-<%= client %>"
+  Address = <%= bacula_storage_address %>
+  SDPort = <%= bacula_storage_port %>
+  Password = "<%= bacula_storage_secret %>"
+  Device = "<%= bacula_filestor_device %>-<%= client %>"
+  Media Type = "<%= bacula_filestor_name %>-<%= client %>"
+  Maximum Concurrent Jobs = 10
+
+  TLS Enable = yes
+  TLS Require = yes
+  TLS CA Certificate File = "<%= bacula_ca_path %>"
+  # This is a client certificate, used by the director to connect to the storage daemon
+  TLS Certificate = "<%= bacula_ssl_client_cert %>"
+  TLS Key = "<%= bacula_ssl_client_key %>"
+}
+
+########################################################################
+# Pool definition                                                      #
+########################################################################
+Pool {
+  Name = "poolfull-<%=bacula_pool_name%>-<%= client %>"
+  Pool Type = Backup
+  Storage = "<%=bacula_filestor_name%>-<%= client %>"
+  Recycle = no
+  AutoPrune = yes
+  Volume Retention = 1 year
+  Label Format = "<%= bacula_pool_name %>-full-<%= client %>.${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}_${Hour:p/2/0/r}:${Minute:p/2/0/r}"
+  Volume Use Duration = 23h
+  Maximum Volume Jobs = 1
+  Maximum Volume Bytes = 50G
+  Action On Purge = Truncate
+}
+
+Pool {
+  Name = "pooldiff-<%=bacula_pool_name%>-<%= client %>"
+  Pool Type = Backup
+  Storage = "<%=bacula_filestor_name%>-<%= client %>"
+  Recycle = no
+  AutoPrune = yes
+  Volume Retention = 1 year
+  Label Format = "<%= bacula_pool_name %>-diff-<%= client %>.${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}_${Hour:p/2/0/r}:${Minute:p/2/0/r}"
+  Volume Use Duration = 23h
+  Maximum Volume Jobs = 1
+  Maximum Volume Bytes = 50G
+  Action On Purge = Truncate
+}
+
+Pool {
+  Name = "poolinc-<%=bacula_pool_name%>-<%= client %>"
+  Pool Type = Backup
+  Storage = "<%=bacula_filestor_name%>-<%= client %>"
+  Recycle = no
+  AutoPrune = yes
+  Volume Retention = 2 months
+  Label Format = "<%= bacula_pool_name %>-inc-<%= client %>.${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}_${Hour:p/2/0/r}:${Minute:p/2/0/r}"
+  Volume Use Duration = 23h
+  Maximum Volume Jobs = 1
+  Maximum Volume Bytes = 50G
+  Action On Purge = Truncate
+}
diff --git a/modules/bacula/templates/storage-per-client.conf.erb b/modules/bacula/templates/storage-per-client.conf.erb
new file mode 100644 (file)
index 0000000..2ce1071
--- /dev/null
@@ -0,0 +1,16 @@
+##
+## THIS FILE IS UNDER PUPPET CONTROL. DON'T EDIT IT HERE.
+## USE: git clone git+ssh://$USER@puppet.debian.org/srv/puppet.debian.org/git/dsa-puppet.git
+##
+
+Device {
+  Name = "<%= bacula_filestor_device %>-<%= client %>"
+  Media Type = "<%= bacula_filestor_name %>-<%= client %>"
+  Archive Device = "<%= bacula_backup_path %>/<%= client %>"
+  LabelMedia = yes;
+  Random Access = Yes;
+  AutomaticMount = yes;
+  RemovableMedia = no;
+  AlwaysOpen = no;
+  Maximum Network Buffer Size = 524288
+}