e49ff2b328e904e14d4676c87ce2e97c8e4082e8
[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 define bacula::storage::client(
8   String $director_server,
9   Stdlib::Host $client = $name
10 ) {
11   include bacula::storage
12
13   $device_name     = "${bacula::storage::filestor_device}-${client}"
14   $media_type_name = "${bacula::storage::filestor_name}-${client}"
15   $directory       = "${bacula::storage::backup_path}/${client}"
16
17   # this is created in both bacula::storage::client and
18   # bacula::storage::director and needs to be the same
19   $dir_storage_secret = hkdf('/etc/puppet/secret', "bacula::director<->storage::${director_server}<->${::fqdn}")
20
21   file {
22     "/etc/bacula/storage-conf.d/${client}.conf":
23       content => template('bacula/storage/sd-per-client.conf.erb'),
24       mode    => '0440',
25       group   => bacula,
26       notify  => Exec['bacula-sd restart-when-idle'],
27       ;
28     $directory:
29       ensure => directory,
30       mode   => '0755',
31       owner  => bacula,
32       group  => bacula,
33       ;
34   }
35
36   # enable the director to make (client, storage) specific configuration
37   @@bacula::director::client_from_storage { $client:
38     tag                     => "bacula::to-director::${director_server}",
39     client                  => $client,
40     storage_address         => $bacula::storage::storage_address,
41     port_sd                 => $bacula::storage::port_sd,
42     storage_secret          => $dir_storage_secret,
43     storage_device_name     => $device_name,
44     storage_media_type_name => $media_type_name,
45   }
46 }