Split the director config coming from each node in two parts: one that comes from...
[mirror/dsa-puppet.git] / modules / bacula / manifests / director.pp
1 # our bacula director
2 #
3 # @param pool_name  A string 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_sslca   SSL CA store for DB access
9 class bacula::director(
10   String  $db_address,
11   Integer $db_port,
12   String  $db_name = 'bacula',
13   String  $db_user = 'bacula',
14   String  $pool_name = 'bacula',
15   Optional[String] $db_sslca = undef,
16 ) inherits bacula {
17
18   ensure_packages ( [
19     'bacula-director-pgsql',
20     'bacula-common',
21     'bacula-common-pgsql'
22   ], {
23     ensure => 'installed',
24   })
25
26   service { 'bacula-director':
27     ensure    => running,
28     enable    => true,
29     hasstatus => true,
30     require   => Package['bacula-director-pgsql']
31   }
32   dsa_systemd::override { 'bacula-director':
33     content => @(EOT)
34       [Unit]
35       After=unbound.service
36       | EOT
37   }
38
39   exec { 'bacula-director reload':
40     path        => '/usr/bin:/usr/sbin:/bin:/sbin',
41     command     => 'service bacula-director reload',
42     refreshonly => true,
43   }
44
45   file { '/etc/bacula/conf.d':
46     ensure  => directory,
47     mode    => '0755',
48     group   => bacula,
49     purge   => true,
50     force   => true,
51     recurse => true,
52     source  => 'puppet:///files/empty/',
53     notify  => Exec['bacula-director reload']
54   }
55
56   file { '/etc/bacula/bacula-dir.conf':
57     content => template('bacula/bacula-dir.conf.erb'),
58     mode    => '0440',
59     group   => bacula,
60     require => Package['bacula-director-pgsql'],
61     notify  => Exec['bacula-director reload']
62   }
63
64   file { '/etc/bacula/conf.d/empty.conf':
65     content => '',
66     mode    => '0440',
67     group   => bacula,
68     require => Package['bacula-director-pgsql'],
69     notify  => Exec['bacula-director reload']
70   }
71
72   Bacula::Director::Client             <<| tag == "bacula::to-director::${::fqdn}" |>>
73   Bacula::Director::Client_from_stroage<<| tag == "bacula::to-director::${::fqdn}" |>>
74
75   package { 'bacula-console':
76     ensure => installed;
77   }
78
79   file { '/etc/bacula/bconsole.conf':
80     content => template('bacula/bconsole.conf.erb'),
81     mode    => '0640',
82     group   => bacula,
83     require => Package['bacula-console']
84   }
85
86   package { 'python3-psycopg2': ensure => installed }
87   file { '/etc/bacula/scripts/volume-purge-action':
88     mode   => '0555',
89     source => 'puppet:///modules/bacula/volume-purge-action',
90     ;
91   }
92   file { '/etc/bacula/scripts/volumes-delete-old':
93     mode   => '0555',
94     source => 'puppet:///modules/bacula/volumes-delete-old',
95     ;
96   }
97   file { '/etc/bacula/storages-list.d':
98     ensure  => directory,
99     mode    => '0755',
100     group   => bacula,
101     purge   => true,
102     force   => true,
103     recurse => true,
104     source  => 'puppet:///files/empty/',
105   }
106   file { '/usr/local/sbin/dsa-bacula-scheduler':
107     source => 'puppet:///modules/bacula/dsa-bacula-scheduler',
108     mode   => '0555',
109   }
110
111   file { '/etc/cron.d/puppet-bacula-stuff': ensure => absent, }
112   concat::fragment { 'puppet-crontab--bacula-director':
113     target  => '/etc/cron.d/puppet-crontab',
114     content => @(EOF)
115       @daily root chronic /etc/bacula/scripts/volume-purge-action -v
116       @daily root chronic /etc/bacula/scripts/volumes-delete-old -v
117       */3 * * * * root sleep $(( $RANDOM \% 60 )); flock -w 0 -e /usr/local/sbin/dsa-bacula-scheduler /usr/local/sbin/dsa-bacula-scheduler
118       | EOF
119   }
120
121   concat { $bacula::bacula_dsa_client_list:
122   }
123   concat::fragment { 'bacula-dsa-client-list::header' :
124     target  => $bacula::bacula_dsa_client_list,
125     content => '',
126     order   => '00',
127   }
128   Concat::Fragment <<| tag == $bacula::tag_bacula_dsa_client_list |>>
129
130   @@ferm::rule::simple { "bacula::director-to-fd::${::fqdn}":
131     tag         => "bacula::director-to-fd::${::fqdn}",
132     description => 'Allow bacula-fd from the bacula-director',
133     port        => '7', # overridden on collecting
134     saddr       => $bacula::public_addresses,
135   }
136   @@ferm::rule::simple { "bacula::director-to-storage::${::fqdn}":
137     tag         => "bacula::director-to-storage::${::fqdn}",
138     description => 'Allow bacula-storage access from the bacula-director',
139     chain       => 'bacula-sd',
140     saddr       => $bacula::public_addresses,
141   }
142 }