backup-path should be something that only the storage system should need to care...
[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 class bacula::storage (
5   String $backup_path = '/srv/bacula',
6 ) inherits bacula {
7   package { 'bacula-sd':
8     ensure => installed
9   }
10
11   service { 'bacula-sd':
12     ensure    => running,
13     enable    => true,
14     hasstatus => true,
15   }
16   dsa_systemd::override { 'bacula-sd':
17     content => @(EOT)
18       [Service]
19       Group=bacula
20       SupplementaryGroups=ssl-cert
21       | EOT
22   }
23
24   exec { 'bacula-sd restart-when-idle':
25     path        => '/usr/bin:/usr/sbin:/bin:/sbin',
26     command     => "sh -c 'setsid /usr/local/sbin/bacula-idle-restart ${bacula::bacula_storage_port} bacula-sd &'",
27     refreshonly => true,
28     subscribe   => File[$bacula::bacula_ssl_server_cert],
29     require     => File['/usr/local/sbin/bacula-idle-restart'],
30   }
31
32
33   file { '/etc/bacula/bacula-sd.conf':
34     content => template('bacula/bacula-sd.conf.erb'),
35     mode    => '0640',
36     group   => bacula,
37     notify  => Exec['bacula-sd restart-when-idle']
38   }
39
40   file { '/etc/bacula/storage-conf.d':
41     ensure  => directory,
42     mode    => '0755',
43     group   => bacula,
44     purge   => true,
45     force   => true,
46     recurse => true,
47     source  => 'puppet:///files/empty/',
48     notify  => Exec['bacula-sd restart-when-idle']
49   }
50
51   # allow access from director and fds
52   ferm::rule::simple { 'dsa-bacula-sd':
53     description => 'Access to the bacula-storage',
54     port        => $bacula::bacula_storage_port,
55     target      => 'bacula-sd',
56   }
57   Ferm::Rule::Simple <<| tag == "bacula::director-to-storage::${bacula::bacula_director_address}" |>>;
58   Ferm::Rule::Simple <<| tag == "bacula::fd-to-storage::${::fqdn}" |>>;
59
60   file { '/etc/bacula/storage-conf.d/empty.conf':
61     content => '',
62     mode    => '0440',
63     group   => bacula,
64     notify  => Exec['bacula-sd restart-when-idle']
65   }
66
67   package { 'python3-psycopg2': ensure => installed }
68   file { '/usr/local/bin/bacula-unlink-removed-volumes':
69     source => 'puppet:///modules/bacula/bacula-unlink-removed-volumes',
70     mode   => '0555',
71   }
72   file { '/etc/cron.d/puppet-bacula-storage-stuff': ensure => absent, }
73   concat::fragment { 'puppet-crontab--bacula-storage':
74     target  => '/etc/cron.d/puppet-crontab',
75     content => @(EOF)
76       @daily bacula chronic /usr/local/bin/bacula-unlink-removed-volumes -v
77       | EOF
78   }
79
80   Bacula::Storage_per_node<<| |>>
81 }