3 # @param pool_name A token to be used in pool names
4 # @param db_address hostname of the postgres server for the catalog DB
5 # @param db_port port of the postgres server for the catalog DB
6 # @param db_name DB name for the catalog DB
7 # @param db_user username for the postgres server for the catalog DB
8 # @param db_password password for the postgres server for the catalog DB
9 # @param port_dir Port that the director should listen on
10 # @param db_sslca SSL CA store for DB access
11 # @param director_name bacula name of this dir instance
12 # @param director_address address of this dir instance that other instances should connect to (dns name)
13 # @param messages_name name of the Messages Resource
14 class bacula::director(
15 String $db_address = 'localhost',
16 Integer $db_port = 5432,
17 String $db_name = 'bacula',
18 String $db_user = 'bacula',
19 String $db_password = hkdf('/etc/puppet/secret', "bacula-db-${::hostname}"),
20 String $pool_name = 'bacula',
21 Integer $port_dir = 9101,
22 Optional[String] $db_sslca = undef,
23 String $director_name = "${::fqdn}-dir",
24 Stdlib::Host $director_address = $::fqdn,
25 String $messages_name = "Msg-${::fqdn}",
28 # used by e.g. bconsole
29 $director_secret = hkdf('/etc/puppet/secret', "bacula-dir-${::fqdn}")
30 # the RestoreFiles Job needs a Pool and a client. Any valid pool and client.
31 $some_pool_name = "poolfull-${pool_name}-${director_address}"
32 $some_client_name = "${director_address}-fd"
34 # let the SD know we exist
35 @@bacula::storage::director{ $::fqdn:
36 tag => 'bacula::to-storage',
37 director_name => $director_name,
38 director_address => $director_address,
39 messages_name => $messages_name,
41 # let FDs know we exist
42 @@bacula::client::director{ $::fqdn:
43 tag => "bacula::to-fd::${director_address}",
44 director_name => $director_name,
45 director_address => $director_address,
46 messages_name => $messages_name,
50 'bacula-director-pgsql',
54 ensure => 'installed',
57 service { 'bacula-director':
61 require => Package['bacula-director-pgsql']
63 dsa_systemd::override { 'bacula-director':
66 After=network-online.target unbound.service
70 exec { 'bacula-director reload':
71 path => '/usr/bin:/usr/sbin:/bin:/sbin',
72 command => 'service bacula-director reload',
76 file { '/etc/bacula/conf.d':
83 notify => Exec['bacula-director reload']
86 file { '/etc/bacula/bacula-dir.conf':
87 content => template('bacula/bacula-dir.conf.erb'),
90 require => Package['bacula-director-pgsql'],
91 notify => Exec['bacula-director reload']
94 file { '/etc/bacula/conf.d/empty.conf':
98 require => Package['bacula-director-pgsql'],
99 notify => Exec['bacula-director reload']
102 Bacula::Director::Client_from_storage<<| tag == "bacula::to-director::${::fqdn}" |>>
103 Bacula::Director::Client <<| tag == "bacula::to-director::${::fqdn}" |>>
105 package { 'bacula-console':
109 file { '/etc/bacula/bconsole.conf':
110 content => template('bacula/bconsole.conf.erb'),
113 require => Package['bacula-console']
116 package { 'python3-psycopg2': ensure => installed }
117 file { '/etc/bacula/scripts/volume-purge-action':
119 source => 'puppet:///modules/bacula/volume-purge-action',
122 file { '/etc/bacula/scripts/volumes-delete-old':
124 source => 'puppet:///modules/bacula/volumes-delete-old',
127 file { '/etc/bacula/storages-list.d':
135 file { '/usr/local/sbin/dsa-bacula-scheduler':
136 source => 'puppet:///modules/bacula/dsa-bacula-scheduler',
140 file { '/etc/cron.d/puppet-bacula-stuff': ensure => absent, }
141 concat::fragment { 'puppet-crontab--bacula-director':
142 target => '/etc/cron.d/puppet-crontab',
143 content => @("EOF"/$)
144 @daily root chronic /etc/bacula/scripts/volume-purge-action -v
145 @daily root chronic /etc/bacula/scripts/volumes-delete-old -v --token '${pool_name}'
146 */3 * * * * root sleep $(( \$RANDOM \\% 60 )); flock -w 0 -e /usr/local/sbin/dsa-bacula-scheduler /usr/local/sbin/dsa-bacula-scheduler
150 concat { $bacula::bacula_dsa_client_list:
151 ensure_newline => true,
153 Concat::Fragment <<| tag == $bacula::tag_bacula_dsa_client_list |>>
155 @@ferm::rule::simple { "bacula::director-to-fd::${::fqdn}":
156 tag => "bacula::director-to-fd::${::fqdn}",
157 description => 'Allow bacula-fd from the bacula-director',
158 port => '7', # overridden on collecting
159 saddr => $bacula::public_addresses,
161 @@ferm::rule::simple { "bacula::director-to-storage::${::fqdn}":
162 tag => 'bacula::director-to-storage',
163 description => 'Allow bacula-storage access from the bacula-director',
164 chain => 'bacula-sd',
165 saddr => $bacula::public_addresses,