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