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