From: Peter Palfrader Date: Wed, 25 Sep 2019 09:50:42 +0000 (+0200) Subject: Make rentention periods configurable with hiera, per client X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=825e27050780ecccd54fb81d9d8f0ce7a3395caf;p=mirror%2Fdsa-puppet.git Make rentention periods configurable with hiera, per client --- diff --git a/modules/bacula/manifests/client.pp b/modules/bacula/manifests/client.pp index bfceebf72..83d025307 100644 --- a/modules/bacula/manifests/client.pp +++ b/modules/bacula/manifests/client.pp @@ -8,12 +8,22 @@ # @param port_fd port that bacula-fd listens on # @param client_name bacula client name for this instance # @param ensure present or absent +# @param volume_retention_full how long to keep volumes with full backups +# @param volume_retention_diff how long to keep volumes with differential backups +# @param volume_retention_inc how long to keep volumes with incremental backups +# @param file_retention how long to keep information about which files are in which volumes/jobs +# @param job_retention how long to keep job records class bacula::client( Stdlib::Host $director_server, Stdlib::Host $storage_server, Integer $port_fd = 9102, String $client_name = "${::fqdn}-fd", Enum['present', 'absent'] $ensure = defined(Class['bacula::not_a_client']) ? { true => 'absent', default => 'present' }, + String $volume_retention_full = '100 days', + String $volume_retention_diff = '50 days', + String $volume_retention_inc = '30 days', + String $file_retention = '30 days', + String $job_retention = $volume_retention_full, ) inherits bacula { $package_ensure = $ensure ? { 'present' => 'installed', 'absent' => 'purged' } $service_ensure = $ensure ? { 'present' => 'running', 'absent' => 'stopped' } @@ -39,9 +49,12 @@ class bacula::client( } @@bacula::storage::client { $client: - tag => "bacula::to-storage::${storage_server}", - client => $client, - director_server => $director_server, + tag => "bacula::to-storage::${storage_server}", + client => $client, + director_server => $director_server, + volume_retention_full => $volume_retention_full, + volume_retention_diff => $volume_retention_diff, + volume_retention_inc => $volume_retention_inc, } @@concat::fragment { "bacula-dsa-client-list::${client}": diff --git a/modules/bacula/manifests/client/director.pp b/modules/bacula/manifests/client/director.pp index a43000de6..ec885c28a 100644 --- a/modules/bacula/manifests/client/director.pp +++ b/modules/bacula/manifests/client/director.pp @@ -15,11 +15,13 @@ define bacula::client::director( $dir_client_secret = hkdf('/etc/puppet/secret', "bacula::director<->fd::${director_address}<->${::fqdn}") @@bacula::director::client { $bacula::client::client: - port_fd => $bacula::client::port_fd, - client => $bacula::client::client, - client_name => $bacula::client::client_name, - client_secret => $dir_client_secret, - tag => "bacula::to-director::${director_address}", + tag => "bacula::to-director::${director_address}", + port_fd => $bacula::client::port_fd, + client => $bacula::client::client, + client_name => $bacula::client::client_name, + client_secret => $dir_client_secret, + file_retention => $bacula::client::file_retention, + job_retention => $bacula::client::job_retention, } file { diff --git a/modules/bacula/manifests/director/client.pp b/modules/bacula/manifests/director/client.pp index 09117c66b..cbfd13984 100644 --- a/modules/bacula/manifests/director/client.pp +++ b/modules/bacula/manifests/director/client.pp @@ -2,15 +2,19 @@ # # This is stored config by a client, collected on the director # -# @param port_fd port that this node's bacula-fd is listening on -# @param client name of the client (relevant for device names, media type names, etc.) -# @param client_name bacula client name -# @param client_secret shared secret between director and client +# @param port_fd port that this node's bacula-fd is listening on +# @param client name of the client (relevant for device names, media type names, etc.) +# @param client_name bacula client name +# @param client_secret shared secret between director and client +# @param file_retention how long to keep information about which files are in which volumes/jobs +# @param job_retention how long to keep job records define bacula::director::client ( Integer $port_fd, Stdlib::Host $client = $name, String $client_name, String $client_secret, + String $file_retention = '30 days', # XXX remove defaults + String $job_retention = '100 days', # XXX remove defaults ) { include bacula::director diff --git a/modules/bacula/manifests/director/client_from_storage.pp b/modules/bacula/manifests/director/client_from_storage.pp index aff272088..b6c8eec56 100644 --- a/modules/bacula/manifests/director/client_from_storage.pp +++ b/modules/bacula/manifests/director/client_from_storage.pp @@ -9,12 +9,18 @@ # @param storage_secret Shared secret between storage and director # @param storage_device_name Device name on the storage daemon for this node's backups # @param storage_media_type_name Media type name on the storage daemon for this node's backupse +# @param volume_retention_full how long to keep volumes with full backups +# @param volume_retention_diff how long to keep volumes with differential backups +# @param volume_retention_inc how long to keep volumes with incremental backups define bacula::director::client_from_storage ( Stdlib::Host $storage_address, Integer $port_sd, String $storage_secret, String $storage_device_name, String $storage_media_type_name, + String $volume_retention_full = '100 days', # XXX remove defaults + String $volume_retention_diff = '50 days', # XXX remove defaults + String $volume_retention_inc = '30 days', # XXX remove defaults Stdlib::Host $client = $name, ) { diff --git a/modules/bacula/manifests/storage/client.pp b/modules/bacula/manifests/storage/client.pp index e49ff2b32..12573008e 100644 --- a/modules/bacula/manifests/storage/client.pp +++ b/modules/bacula/manifests/storage/client.pp @@ -4,9 +4,15 @@ # # @param director_server director for this client # @param client name/address of the client (relevant for device names, media type names, etc.) +# @param volume_retention_full how long to keep volumes with full backups +# @param volume_retention_diff how long to keep volumes with differential backups +# @param volume_retention_inc how long to keep volumes with incremental backups define bacula::storage::client( String $director_server, - Stdlib::Host $client = $name + Stdlib::Host $client = $name, + String $volume_retention_full = '100 days', # XXX remove defaults + String $volume_retention_diff = '50 days', # XXX remove defaults + String $volume_retention_inc = '30 days', # XXX remove defaults ) { include bacula::storage @@ -42,5 +48,8 @@ define bacula::storage::client( storage_secret => $dir_storage_secret, storage_device_name => $device_name, storage_media_type_name => $media_type_name, + volume_retention_full => $volume_retention_full, + volume_retention_diff => $volume_retention_diff, + volume_retention_inc => $volume_retention_inc, } } diff --git a/modules/bacula/templates/director/dir-per-client-from-storage.erb b/modules/bacula/templates/director/dir-per-client-from-storage.erb index 8a634430e..5f67f7166 100644 --- a/modules/bacula/templates/director/dir-per-client-from-storage.erb +++ b/modules/bacula/templates/director/dir-per-client-from-storage.erb @@ -33,7 +33,7 @@ Pool { Pool Type = Backup Storage = "<%= @storage_name %>" AutoPrune = yes - Volume Retention = 100 days + Volume Retention = <%= @volume_retention_full %> Label Format = "<%= @pool_name %>-full.${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 @@ -48,7 +48,7 @@ Pool { Pool Type = Backup Storage = "<%= @storage_name %>" AutoPrune = yes - Volume Retention = 50 days + Volume Retention = <%= @volume_retention_diff %> Label Format = "<%= @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 @@ -63,7 +63,7 @@ Pool { Pool Type = Backup Storage = "<%= @storage_name %>" AutoPrune = yes - Volume Retention = 30 days + Volume Retention = <%= @volume_retention_inc %> Label Format = "<%= @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 diff --git a/modules/bacula/templates/director/dir-per-client.erb b/modules/bacula/templates/director/dir-per-client.erb index 713bc3e13..15a77c282 100644 --- a/modules/bacula/templates/director/dir-per-client.erb +++ b/modules/bacula/templates/director/dir-per-client.erb @@ -28,8 +28,8 @@ Client { FDPort = <%= @port_fd %> Catalog = MyCatalog Password = "<%= @client_secret %>" - File Retention = 30 days - Job Retention = 3 months + File Retention = <%= @file_retention %> + Job Retention = <%= @job_retention %> AutoPrune = yes TLS Enable = yes