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