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