/
storage.pp
103 lines (94 loc) · 3.2 KB
/
storage.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# This class configures the Bacula storage daemon.
#
# @param conf_dir
# @param device
# @param device_mode
# @param device_password
# @param device_seltype
# @param director_name
# @param group
# @param homedir
# @param listen_address INET or INET6 address to listen on
# @param maxconcurjobs
# @param media_type
# @param packages
# @param port The listening port for the Storage Daemon
# @param rundir
# @param rundir
# @param services
# @param storage
# @param user
#
class bacula::storage (
String $services,
Array $packages,
String $conf_dir = $bacula::conf_dir,
String $device = '/bacula',
Stdlib::Filemode $device_mode = '0770',
String $device_name = "${trusted['certname']}-device",
String $device_owner = $bacula::bacula_user,
String $device_seltype = $bacula::device_seltype,
String $director_name = $bacula::director_name,
String $group = $bacula::bacula_group,
String $homedir = $bacula::homedir,
Stdlib::Ip_address $listen_address = $facts['ipaddress'],
Integer $maxconcurjobs = 5,
String $media_type = 'File',
String $password = 'secret',
Integer $port = 9103,
String $rundir = $bacula::rundir,
String $storage = $trusted['certname'], # storage here is not storage_name
String $address = $facts['fqdn'],
String $user = $bacula::bacula_user,
) inherits ::bacula {
# Allow for package names to include EPP syntax for db_type
$db_type = lookup('bacula::director::db_type')
$package_names = $packages.map |$p| {
$package_name = inline_epp($p, {
'db_type' => $db_type
})
}
ensure_packages($package_names)
service { $services:
ensure => running,
enable => true,
require => Package[$package_names],
}
concat::fragment { 'bacula-storage-header':
order => '00',
target => "${conf_dir}/bacula-sd.conf",
content => template('bacula/bacula-sd-header.erb'),
}
bacula::storage::device { $device_name:
device => $device,
maxconcurjobs => $maxconcurjobs,
}
concat::fragment { 'bacula-storage-dir':
target => "${conf_dir}/bacula-sd.conf",
content => template('bacula/bacula-sd-dir.erb'),
}
bacula::messages { 'Standard-sd':
daemon => 'sd',
director => "${director_name}-dir = all",
append => '"/var/log/bacula/bacula-sd.log" = all, !skipped',
}
# Realize the clause the director is exporting here so we can allow access to
# the storage daemon Adds an entry to ${conf_dir}/bacula-sd.conf
Concat::Fragment <<| tag == "bacula-storage-dir-${director_name}" |>>
concat { "${conf_dir}/bacula-sd.conf":
owner => 'root',
group => $group,
mode => '0640',
show_diff => false,
notify => Service[$services],
}
@@bacula::director::storage { $storage:
address => $address,
port => $port,
password => $password,
device_name => $device_name,
media_type => $media_type,
maxconcurjobs => $maxconcurjobs,
tag => "bacula-${director_name}",
}
}