I do not think empty directories need a source => (these days)
[mirror/dsa-puppet.git] / modules / bacula / manifests / director.pp
1 # our bacula director
2 #
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 class bacula::director(
14   String  $db_address,
15   Integer $db_port,
16   String  $db_name = 'bacula',
17   String  $db_user = 'bacula',
18   String  $db_password = hkdf('/etc/puppet/secret', "bacula-db-${::hostname}"),
19   String  $pool_name = 'bacula',
20   Integer $port_dir = 9101,
21   Optional[String] $db_sslca = undef,
22   #String $director_name    = "${::fqdn}-dir",
23   String $director_name = $bacula::bacula_director_name,
24   Stdlib::Host $director_address = $::fqdn,
25 ) inherits bacula {
26
27   # used by e.g. bconsole
28   $director_secret = hkdf('/etc/puppet/secret', "bacula-dir-${::fqdn}")
29   # the RestoreFiles Job needs a Pool and a client.  Any valid pool and client.
30   $some_pool_name = "poolfull-${pool_name}-${director_address}"
31   $some_client_name = "${director_address}-fd"
32
33   # let the SD know we exist
34   @@bacula::storage::director{ $::fqdn:
35     tag              => 'bacula::to-storage',
36     director_name    => $director_name,
37     director_address => $director_address,
38   }
39   # let FDs know we exist
40   @@bacula::client::director{ $::fqdn:
41     tag              => "bacula::to-fd::${director_address}",
42     director_name    => $director_name,
43     director_address => $director_address,
44   }
45
46   ensure_packages ( [
47     'bacula-director-pgsql',
48     'bacula-common',
49     'bacula-common-pgsql'
50   ], {
51     ensure => 'installed',
52   })
53
54   service { 'bacula-director':
55     ensure    => running,
56     enable    => true,
57     hasstatus => true,
58     require   => Package['bacula-director-pgsql']
59   }
60   dsa_systemd::override { 'bacula-director':
61     content => @(EOT)
62       [Unit]
63       After=unbound.service
64       | EOT
65   }
66
67   exec { 'bacula-director reload':
68     path        => '/usr/bin:/usr/sbin:/bin:/sbin',
69     command     => 'service bacula-director reload',
70     refreshonly => true,
71   }
72
73   file { '/etc/bacula/conf.d':
74     ensure  => directory,
75     mode    => '0755',
76     group   => bacula,
77     purge   => true,
78     force   => true,
79     recurse => true,
80     notify  => Exec['bacula-director reload']
81   }
82
83   file { '/etc/bacula/bacula-dir.conf':
84     content => template('bacula/bacula-dir.conf.erb'),
85     mode    => '0440',
86     group   => bacula,
87     require => Package['bacula-director-pgsql'],
88     notify  => Exec['bacula-director reload']
89   }
90
91   file { '/etc/bacula/conf.d/empty.conf':
92     content => '',
93     mode    => '0440',
94     group   => bacula,
95     require => Package['bacula-director-pgsql'],
96     notify  => Exec['bacula-director reload']
97   }
98
99   Bacula::Director::Client             <<| tag == "bacula::to-director::${::fqdn}" |>>
100   Bacula::Director::Client_from_storage<<| tag == "bacula::to-director::${::fqdn}" |>>
101
102   package { 'bacula-console':
103     ensure => installed;
104   }
105
106   file { '/etc/bacula/bconsole.conf':
107     content => template('bacula/bconsole.conf.erb'),
108     mode    => '0640',
109     group   => bacula,
110     require => Package['bacula-console']
111   }
112
113   package { 'python3-psycopg2': ensure => installed }
114   file { '/etc/bacula/scripts/volume-purge-action':
115     mode   => '0555',
116     source => 'puppet:///modules/bacula/volume-purge-action',
117     ;
118   }
119   file { '/etc/bacula/scripts/volumes-delete-old':
120     mode   => '0555',
121     source => 'puppet:///modules/bacula/volumes-delete-old',
122     ;
123   }
124   file { '/etc/bacula/storages-list.d':
125     ensure  => directory,
126     mode    => '0755',
127     group   => bacula,
128     purge   => true,
129     force   => true,
130     recurse => true,
131   }
132   file { '/usr/local/sbin/dsa-bacula-scheduler':
133     source => 'puppet:///modules/bacula/dsa-bacula-scheduler',
134     mode   => '0555',
135   }
136
137   file { '/etc/cron.d/puppet-bacula-stuff': ensure => absent, }
138   concat::fragment { 'puppet-crontab--bacula-director':
139     target  => '/etc/cron.d/puppet-crontab',
140     content => @(EOF)
141       @daily root chronic /etc/bacula/scripts/volume-purge-action -v
142       @daily root chronic /etc/bacula/scripts/volumes-delete-old -v
143       */3 * * * * root sleep $(( $RANDOM \% 60 )); flock -w 0 -e /usr/local/sbin/dsa-bacula-scheduler /usr/local/sbin/dsa-bacula-scheduler
144       | EOF
145   }
146
147   concat { $bacula::bacula_dsa_client_list:
148   }
149   concat::fragment { 'bacula-dsa-client-list::header' :
150     target  => $bacula::bacula_dsa_client_list,
151     content => '',
152     order   => '00',
153   }
154   Concat::Fragment <<| tag == $bacula::tag_bacula_dsa_client_list |>>
155
156   @@ferm::rule::simple { "bacula::director-to-fd::${::fqdn}":
157     tag         => "bacula::director-to-fd::${::fqdn}",
158     description => 'Allow bacula-fd from the bacula-director',
159     port        => '7', # overridden on collecting
160     saddr       => $bacula::public_addresses,
161   }
162   @@ferm::rule::simple { "bacula::director-to-storage::${::fqdn}":
163     tag         => 'bacula::director-to-storage',
164     description => 'Allow bacula-storage access from the bacula-director',
165     chain       => 'bacula-sd',
166     saddr       => $bacula::public_addresses,
167   }
168 }