Make rentention periods configurable with hiera, per client
[mirror/dsa-puppet.git] / modules / bacula / manifests / storage / client.pp
1 # Bacula storage configuration for a client.
2 #
3 # This is stored config by a client and then collected on the storage
4 #
5 # @param director_server  director for this client
6 # @param client           name/address of the client (relevant for device names, media type names, etc.)
7 # @param volume_retention_full  how long to keep volumes with full backups
8 # @param volume_retention_diff  how long to keep volumes with differential backups
9 # @param volume_retention_inc   how long to keep volumes with incremental backups
10 define bacula::storage::client(
11   String $director_server,
12   Stdlib::Host $client = $name,
13   String $volume_retention_full = '100 days', # XXX remove defaults
14   String $volume_retention_diff = '50 days', # XXX remove defaults
15   String $volume_retention_inc  = '30 days', # XXX remove defaults
16 ) {
17   include bacula::storage
18
19   $device_name     = "${bacula::storage::filestor_device}-${client}"
20   $media_type_name = "${bacula::storage::filestor_name}-${client}"
21   $directory       = "${bacula::storage::backup_path}/${client}"
22
23   # this is created in both bacula::storage::client and
24   # bacula::storage::director and needs to be the same
25   $dir_storage_secret = hkdf('/etc/puppet/secret', "bacula::director<->storage::${director_server}<->${::fqdn}")
26
27   file {
28     "/etc/bacula/storage-conf.d/${client}.conf":
29       content => template('bacula/storage/sd-per-client.conf.erb'),
30       mode    => '0440',
31       group   => bacula,
32       notify  => Exec['bacula-sd restart-when-idle'],
33       ;
34     $directory:
35       ensure => directory,
36       mode   => '0755',
37       owner  => bacula,
38       group  => bacula,
39       ;
40   }
41
42   # enable the director to make (client, storage) specific configuration
43   @@bacula::director::client_from_storage { $client:
44     tag                     => "bacula::to-director::${director_server}",
45     client                  => $client,
46     storage_address         => $bacula::storage::storage_address,
47     port_sd                 => $bacula::storage::port_sd,
48     storage_secret          => $dir_storage_secret,
49     storage_device_name     => $device_name,
50     storage_media_type_name => $media_type_name,
51     volume_retention_full   => $volume_retention_full,
52     volume_retention_diff   => $volume_retention_diff,
53     volume_retention_inc    => $volume_retention_inc,
54   }
55 }