69e8ddc44c326fd80352fd7aac21c5c74779091f
[mirror/dsa-puppet.git] / modules / bacula / manifests / storage.pp
1 # the bacula storage node
2 #
3 # @param backup_path the directory where backups should be stored
4 # @param filestor_device Storage device name prefix
5 # @param filestor_name Storage device media type name prefix
6 # @param port_sd Port for the sd to listen on
7 class bacula::storage (
8   String $backup_path     = '/srv/bacula',
9   String $filestor_device = 'FileStorage',
10   String $filestor_name   = 'File',
11   Integer $port_sd        = 9103,
12 ) inherits bacula {
13   $storage_secret = hkdf('/etc/puppet/secret', "bacula-sd-${::fqdn}")
14
15   package { 'bacula-sd':
16     ensure => installed
17   }
18
19   service { 'bacula-sd':
20     ensure    => running,
21     enable    => true,
22     hasstatus => true,
23   }
24   dsa_systemd::override { 'bacula-sd':
25     content => @(EOT)
26       [Service]
27       Group=bacula
28       SupplementaryGroups=ssl-cert
29       | EOT
30   }
31
32   exec { 'bacula-sd restart-when-idle':
33     path        => '/usr/bin:/usr/sbin:/bin:/sbin',
34     command     => "sh -c 'setsid /usr/local/sbin/bacula-idle-restart ${port_sd} bacula-sd &'",
35     refreshonly => true,
36     subscribe   => File[$bacula::bacula_ssl_server_cert],
37     require     => File['/usr/local/sbin/bacula-idle-restart'],
38   }
39
40
41   file { '/etc/bacula/bacula-sd.conf':
42     content => template('bacula/bacula-sd.conf.erb'),
43     mode    => '0640',
44     group   => bacula,
45     notify  => Exec['bacula-sd restart-when-idle']
46   }
47
48   file { '/etc/bacula/storage-conf.d':
49     ensure  => directory,
50     mode    => '0755',
51     group   => bacula,
52     purge   => true,
53     force   => true,
54     recurse => true,
55     source  => 'puppet:///files/empty/',
56     notify  => Exec['bacula-sd restart-when-idle']
57   }
58
59   # allow access from director and fds
60   ferm::rule::simple { 'dsa-bacula-sd':
61     description => 'Access to the bacula-storage',
62     port        => $port_sd,
63     target      => 'bacula-sd',
64   }
65   Ferm::Rule::Simple <<| tag == "bacula::director-to-storage::${bacula::bacula_director_address}" |>>;
66   Ferm::Rule::Simple <<| tag == "bacula::fd-to-storage::${::fqdn}" |>>;
67
68   file { '/etc/bacula/storage-conf.d/empty.conf':
69     content => '',
70     mode    => '0440',
71     group   => bacula,
72     notify  => Exec['bacula-sd restart-when-idle']
73   }
74
75   package { 'python3-psycopg2': ensure => installed }
76   file { '/usr/local/bin/bacula-unlink-removed-volumes':
77     source => 'puppet:///modules/bacula/bacula-unlink-removed-volumes',
78     mode   => '0555',
79   }
80   file { '/etc/cron.d/puppet-bacula-storage-stuff': ensure => absent, }
81   concat::fragment { 'puppet-crontab--bacula-storage':
82     target  => '/etc/cron.d/puppet-crontab',
83     content => @(EOF)
84       @daily bacula chronic /usr/local/bin/bacula-unlink-removed-volumes -v
85       | EOF
86   }
87
88   Bacula::Storage::Client<<| tag == "bacula::to-storage::${::fqdn}" |>>
89 }