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 $real_email_error = $bacula::email_error ? { true => $bacula::email_error , default => 'root@localhost' }
35 $real_email_operator = $bacula::email_operator ? { true => $bacula::email_operator, default => 'root@localhost' }
36 $real_email_daemon = $bacula::email_daemon ? { true => $bacula::email_daemon , default => 'root@localhost' }
38 # let the SD know we exist
39 @@bacula::storage::director{ $::fqdn:
40 tag => 'bacula::to-storage',
41 director_name => $director_name,
42 director_address => $director_address,
43 messages_name => $messages_name,
45 # let FDs know we exist
46 @@bacula::client::director{ $::fqdn:
47 tag => "bacula::to-fd::${director_address}",
48 director_name => $director_name,
49 director_address => $director_address,
50 messages_name => $messages_name,
54 'bacula-director-pgsql',
58 ensure => 'installed',
61 service { 'bacula-director':
65 require => Package['bacula-director-pgsql']
67 dsa_systemd::override { 'bacula-director':
70 After=network-online.target unbound.service
74 exec { 'bacula-director reload':
75 path => '/usr/bin:/usr/sbin:/bin:/sbin',
76 command => 'service bacula-director reload',
80 file { '/etc/bacula/conf.d':
87 notify => Exec['bacula-director reload']
90 file { '/etc/bacula/bacula-dir.conf':
91 content => template('bacula/bacula-dir.conf.erb'),
94 require => Package['bacula-director-pgsql'],
95 notify => Exec['bacula-director reload']
98 file { '/etc/bacula/conf.d/empty.conf':
102 require => Package['bacula-director-pgsql'],
103 notify => Exec['bacula-director reload']
106 Bacula::Director::Client_from_storage<<| tag == "bacula::to-director::${::fqdn}" |>>
107 Bacula::Director::Client <<| tag == "bacula::to-director::${::fqdn}" |>>
109 package { 'bacula-console':
113 file { '/etc/bacula/bconsole.conf':
114 content => template('bacula/bconsole.conf.erb'),
117 require => Package['bacula-console']
120 package { 'python3-psycopg2': ensure => installed }
121 file { '/etc/bacula/scripts/volume-purge-action':
123 source => 'puppet:///modules/bacula/volume-purge-action',
126 file { '/etc/bacula/scripts/volumes-delete-old':
128 source => 'puppet:///modules/bacula/volumes-delete-old',
131 file { '/etc/bacula/storages-list.d':
139 file { '/usr/local/sbin/dsa-bacula-scheduler':
140 source => 'puppet:///modules/bacula/dsa-bacula-scheduler',
144 file { '/etc/cron.d/puppet-bacula-stuff': ensure => absent, }
145 concat::fragment { 'puppet-crontab--bacula-director':
146 target => '/etc/cron.d/puppet-crontab',
147 content => @("EOF"/$)
148 @daily root chronic /etc/bacula/scripts/volume-purge-action -v
149 @daily root chronic /etc/bacula/scripts/volumes-delete-old -v --token '${pool_name}'
150 */3 * * * * root sleep $(( \$RANDOM \\% 60 )); flock -w 0 -e /usr/local/sbin/dsa-bacula-scheduler /usr/local/sbin/dsa-bacula-scheduler
154 concat { $bacula::bacula_dsa_client_list:
155 ensure_newline => true,
157 Concat::Fragment <<| tag == $bacula::tag_bacula_dsa_client_list |>>
159 @@ferm::rule::simple { "bacula::director-to-fd::${::fqdn}":
160 tag => "bacula::director-to-fd::${::fqdn}",
161 description => 'Allow bacula-fd from the bacula-director',
162 port => '7', # overridden on collecting
163 saddr => $bacula::public_addresses,
165 @@ferm::rule::simple { "bacula::director-to-storage::${::fqdn}":
166 tag => 'bacula::director-to-storage',
167 description => 'Allow bacula-storage access from the bacula-director',
168 chain => 'bacula-sd',
169 saddr => $bacula::public_addresses,