Skip to content

Commit 1e93248

Browse files
authored
Merge pull request #2 from Project0/develop
Add specs and improve bareos type checking
2 parents 82f7a95 + e7a1aa2 commit 1e93248

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2297
-173
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,3 @@ matrix:
5959
env: PUPPET_GEM_VERSION="~> 4.4.0" STRICT_VARIABLES=yes
6060
- rvm: 2.4
6161
env: PUPPET_GEM_VERSION="~> 4.6.0" STRICT_VARIABLES=yes
62-
- rvm: 2.4
63-
env: PUPPET_GEM_VERSION="~> 5.0.1" STRICT_VARIABLES=yes

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
1. [Description](#description)
99
1. [Setup requirements](#setup-requirements)
1010
1. [Reference](#reference)
11-
* [Bareos common](#class-bareos)
12-
* [Client/Filedaemon](#client-filedaemon)
13-
* [Console (bconsole)](#console)
14-
* [Director](#director)
15-
* [Monitor (Tray)](#monitor)
16-
* [Storage](#storage)
17-
* [Web UI](#webui)
11+
1. [Bareos common](#class-bareos)
12+
1. [Client/Filedaemon](#clientfiledaemon)
13+
1. [Console (bconsole)](#console)
14+
1. [Director](#director)
15+
1. [Monitor (Tray)](#monitor)
16+
1. [Storage](#storage)
17+
1. [Web UI](#webui)
1818
1. [Limitations - OS compatibility, etc.](#limitations)
1919

2020
## Description
2121

22-
Bareos is a 100% open source fork of the backup project from bacula.org.
22+
[Bareos](http://bareos.org/) is a 100% open source fork of the backup project from bacula.org.
2323

2424
This puppet module configures and manage all aspects of an complex bareos installation. Unfortunately backups cannot be handled on an standard way, so this module tends to be flexible as possible. It is recommend to make familiar with the [documentation](http://doc.bareos.org/master/html/bareos-manual-main-reference.html) of the configuration.
2525

lib/puppet/parser/functions/bareos_settings.rb

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module Puppet::Parser::Functions
5151
when 'acl', 'messages', 'type', 'string_noquote', 'schedule_run_command'
5252
raise 'Value need to be an string' unless value.is_a?(String)
5353
# type md5password is missleading, it is an plain password and not md5 hashed
54-
when 'audit-command', 'runscript_short', 'autopassword', 'md5password', 'directory', 'string', 'strname', 'address', 'device', 'plugin_names'
54+
when 'audit_command', 'runscript_short', 'autopassword', 'md5password', 'directory', 'string', 'strname', 'address', 'device', 'plugin_names'
5555
# array
5656
quote = true
5757
raise 'Value need to be an string' unless value.is_a?(String)
@@ -69,11 +69,31 @@ module Puppet::Parser::Functions
6969
when 'include_exclude_item', 'runscript', 'hash'
7070
raise 'Please specify as Hash' unless value.is_a?(Hash)
7171
when 'backup_level'
72-
value_in_array = %w[full incremental differential virtualfull]
72+
value_in_array = %w[full incremental differential virtualfull initcatalog catalog volumetocatalog disktocatalog]
7373
when 'io_direction'
7474
value_in_array = %w[in out both]
7575
when 'action_on_purge'
7676
value_in_array = %w[truncate]
77+
when 'encryption_cipher'
78+
value_in_array = %w[aes128 aes192 aes256 camellia128 camellia192 camellia256 aes128hmacsha1 aes256hmacsha1 blowfish]
79+
when 'auth_type'
80+
value_in_array = %w[clear md5]
81+
when 'auth_protocol_type', 'protocol_type'
82+
value_in_array = %w[native ndmp]
83+
when 'pooltype'
84+
value_in_array = %w[backup archive cloned migration copy save scratch]
85+
when 'label'
86+
value_in_array = %w[ansi ibm bareos]
87+
when 'migration_type'
88+
value_in_array = %w[smallestvolume oldestvolume client volume job sqlquery pooloccupancy pooltime pooluncopiedjobs]
89+
when 'job_type'
90+
value_in_array = %w[backup restore verify admin migrate copy consolidate]
91+
when 'replace_option'
92+
value_in_array = %w[always ifnewer ifolder never]
93+
when 'device_type'
94+
value_in_array = %w[tape file fifo gfapi rados]
95+
when 'compression_algorithm'
96+
value_in_array = %w[gzip lzo lzfast lz4 lz4hc]
7797
else
7898
raise "Invalid setting type '#{type}'"
7999
end

manifests/client/client.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@
393393
}
394394

395395
if $ensure == 'present' {
396-
$_require_res_messages = $messages ? { undef => undef, default => Bareos::Director::Messages[$messages] }
396+
$_require_res_messages = $messages ? { undef => undef, default => Bareos::Client::Messages[$messages] }
397397

398398
$_require_resource = delete_undef_values([
399399
$_require_res_messages,
@@ -451,7 +451,7 @@
451451
$_require_res_messages = undef
452452
}
453453

454-
file { "${::bareos::client::config_dir}/${_resource_dir}/${name}.conf":
454+
file { "${::bareos::client::config_dir}/${_resource_dir}/${name_client}.conf":
455455
ensure => $ensure,
456456
mode => $::bareos::file_mode,
457457
owner => $::bareos::file_owner,

manifests/client/director.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,12 @@
199199
if $ensure == 'present' {
200200
$_settings = bareos_settings(
201201
[$name, 'Name', 'name', true],
202+
[$description, 'Description', 'string', false],
202203
[$address, 'Address', 'string', false],
203204
[$allowed_job_command, 'Allowed Job Command', 'string_list', false],
204205
[$allowed_script_dir, 'Allowed Script Dir', 'directory_list', false],
205206
[$connection_from_client_to_director, 'Connection From Client To Director', 'boolean', false],
206207
[$connection_from_director_to_client, 'Connection From Director To Client', 'boolean', false],
207-
[$description, 'Description', 'string', false],
208208
[$maximum_bandwidth_per_job, 'Maximum Bandwidth Per Job', 'speed', false],
209209
[$monitor, 'Monitor', 'boolean', false],
210210
[$password, 'Password', 'md5password', true],

manifests/director.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,10 @@
5959
require => Package[$package_name],
6060
notify => Service[$service_name],
6161
}
62+
63+
File <| |> -> exec { 'bareos director init catalog':
64+
command => '/usr/lib/bareos/scripts/create_bareos_database && /usr/lib/bareos/scripts/make_bareos_tables && /usr/lib/bareos/scripts/grant_bareos_privileges',
65+
notify => Service[$::bareos::director::service_name],
66+
refreshonly => true,
67+
}
6268
}

manifests/director/catalog.pp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@
178178
)
179179
}
180180

181-
$_exec_create = "bareos catalog create database ${title}"
182181
file { "${::bareos::director::config_dir}/${_resource_dir}/${name}.conf":
183182
ensure => $ensure,
184183
mode => $::bareos::file_mode,
@@ -187,13 +186,7 @@
187186
content => template('bareos/resource.erb'),
188187
notify => [
189188
Service[$::bareos::director::service_name],
190-
Exec[$_exec_create],
189+
Exec['bareos director init catalog'],
191190
]
192191
}
193-
# execute after all config files are written
194-
File <| |> -> exec { $_exec_create:
195-
command => '/usr/lib/bareos/scripts/create_bareos_database && /usr/lib/bareos/scripts/make_bareos_tables && /usr/lib/bareos/scripts/grant_bareos_privileges',
196-
notify => Service[$::bareos::director::service_name],
197-
refreshonly => true,
198-
}
199192
}

manifests/director/client.pp

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,6 @@
6363
# Bareos Default: true
6464
# Required: false
6565
#
66-
# [*fd_address*]
67-
# Fd Address: Alias for Address.
68-
#
69-
# Bareos Datatype: string
70-
# Bareos Default: Not set
71-
# Required: false
72-
#
73-
# [*fd_password*]
74-
# Fd Password
75-
#
76-
# Bareos Datatype: autopassword
77-
# Bareos Default: Not set
78-
# Required: false
79-
#
80-
# [*fd_port*]
81-
# Fd Port
82-
#
83-
# Bareos Datatype: pint32
84-
# Bareos Default: 9102
85-
# Required: false
86-
#
8766
# [*file_retention*]
8867
# File Retention
8968
#
@@ -305,9 +284,6 @@
305284
$connection_from_director_to_client = undef,
306285
$description = undef,
307286
$enabled = undef,
308-
$fd_address = undef,
309-
$fd_password = undef,
310-
$fd_port = undef,
311287
$file_retention = undef,
312288
$hard_quota = undef,
313289
$heartbeat_interval = undef,
@@ -355,25 +331,16 @@
355331
$_require_res_catalog,
356332
])
357333

358-
unless $auth_type == undef or (downcase($auth_type) in [ 'Clear', 'md5' ]) {
359-
fail('Invalid value for auth_type')
360-
}
361-
unless $protocol == undef or (downcase($protocol) in [ 'native', 'ndmp' ]) {
362-
fail('Invalid value for protocol')
363-
}
364334
$_settings = bareos_settings(
365335
[$name, 'Name', 'name', true],
366336
[$description, 'Description', 'string', false],
367337
[$address, 'Address', 'string', true],
368-
[$auth_type, 'Auth Type', 'type', false],
338+
[$auth_type, 'Auth Type', 'auth_type', false],
369339
[$auto_prune, 'Auto Prune', 'boolean', false],
370340
[$catalog, 'Catalog', 'res', false],
371341
[$connection_from_client_to_director, 'Connection From Client To Director', 'boolean', false],
372342
[$connection_from_director_to_client, 'Connection From Director To Client', 'boolean', false],
373343
[$enabled, 'Enabled', 'boolean', false],
374-
[$fd_address, 'Fd Address', 'string', false],
375-
[$fd_password, 'Fd Password', 'autopassword', false],
376-
[$fd_port, 'Fd Port', 'pint32', false],
377344
[$file_retention, 'File Retention', 'time', false],
378345
[$hard_quota, 'Hard Quota', 'size64', false],
379346
[$heartbeat_interval, 'Heartbeat Interval', 'time', false],
@@ -386,7 +353,7 @@
386353
[$passive, 'Passive', 'boolean', false],
387354
[$password, 'Password', 'autopassword', true],
388355
[$port, 'Port', 'pint32', false],
389-
[$protocol, 'Protocol', 'type', false],
356+
[$protocol, 'Protocol', 'auth_protocol_type', false],
390357
[$quota_include_failed_jobs, 'Quota Include Failed Jobs', 'boolean', false],
391358
[$soft_quota, 'Soft Quota', 'size64', false],
392359
[$soft_quota_grace_period, 'Soft Quota Grace Period', 'time', false],

manifests/director/counter.pp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@
5959
}
6060

6161
if $ensure == 'present' {
62+
$_require_res_catalog = $catalog ? { undef => undef, default => Bareos::Director::Catalog[$catalog] }
63+
64+
$_require_resource = delete_undef_values([
65+
$_require_res_catalog,
66+
])
67+
6268
$_settings = bareos_settings(
6369
[$name, 'Name', 'name', true],
6470
[$description, 'Description', 'string', false],
@@ -67,6 +73,8 @@
6773
[$minimum, 'Minimum', 'int32', false],
6874
[$wrap_counter, 'Wrap Counter', 'res', false]
6975
)
76+
} else {
77+
$_require_resource = undef
7078
}
7179

7280
file { "${::bareos::director::config_dir}/${_resource_dir}/${name}.conf":
@@ -76,5 +84,6 @@
7684
group => $::bareos::file_group,
7785
content => template('bareos/resource.erb'),
7886
notify => Service[$::bareos::director::service_name],
87+
require => $_require_resource,
7988
}
8089
}

manifests/director/director.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@
371371
$omit_defaults = undef,
372372
$optimize_for_size = undef,
373373
$optimize_for_speed = undef,
374-
$password = 'set',
374+
$password = 'PleaseChangeMe',
375375
$pid_directory = undef,
376376
$plugin_directory = undef,
377377
$plugin_names = undef,

0 commit comments

Comments
 (0)