Skip to content

Commit

Permalink
Merge pull request #2 from Project0/develop
Browse files Browse the repository at this point in the history
Add specs and improve bareos type checking
  • Loading branch information
project0 authored Aug 15, 2017
2 parents 82f7a95 + e7a1aa2 commit 1e93248
Show file tree
Hide file tree
Showing 50 changed files with 2,297 additions and 173 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,3 @@ matrix:
env: PUPPET_GEM_VERSION="~> 4.4.0" STRICT_VARIABLES=yes
- rvm: 2.4
env: PUPPET_GEM_VERSION="~> 4.6.0" STRICT_VARIABLES=yes
- rvm: 2.4
env: PUPPET_GEM_VERSION="~> 5.0.1" STRICT_VARIABLES=yes
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
1. [Description](#description)
1. [Setup requirements](#setup-requirements)
1. [Reference](#reference)
* [Bareos common](#class-bareos)
* [Client/Filedaemon](#client-filedaemon)
* [Console (bconsole)](#console)
* [Director](#director)
* [Monitor (Tray)](#monitor)
* [Storage](#storage)
* [Web UI](#webui)
1. [Bareos common](#class-bareos)
1. [Client/Filedaemon](#clientfiledaemon)
1. [Console (bconsole)](#console)
1. [Director](#director)
1. [Monitor (Tray)](#monitor)
1. [Storage](#storage)
1. [Web UI](#webui)
1. [Limitations - OS compatibility, etc.](#limitations)

## Description

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

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.

Expand Down
24 changes: 22 additions & 2 deletions lib/puppet/parser/functions/bareos_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module Puppet::Parser::Functions
when 'acl', 'messages', 'type', 'string_noquote', 'schedule_run_command'
raise 'Value need to be an string' unless value.is_a?(String)
# type md5password is missleading, it is an plain password and not md5 hashed
when 'audit-command', 'runscript_short', 'autopassword', 'md5password', 'directory', 'string', 'strname', 'address', 'device', 'plugin_names'
when 'audit_command', 'runscript_short', 'autopassword', 'md5password', 'directory', 'string', 'strname', 'address', 'device', 'plugin_names'
# array
quote = true
raise 'Value need to be an string' unless value.is_a?(String)
Expand All @@ -69,11 +69,31 @@ module Puppet::Parser::Functions
when 'include_exclude_item', 'runscript', 'hash'
raise 'Please specify as Hash' unless value.is_a?(Hash)
when 'backup_level'
value_in_array = %w[full incremental differential virtualfull]
value_in_array = %w[full incremental differential virtualfull initcatalog catalog volumetocatalog disktocatalog]
when 'io_direction'
value_in_array = %w[in out both]
when 'action_on_purge'
value_in_array = %w[truncate]
when 'encryption_cipher'
value_in_array = %w[aes128 aes192 aes256 camellia128 camellia192 camellia256 aes128hmacsha1 aes256hmacsha1 blowfish]
when 'auth_type'
value_in_array = %w[clear md5]
when 'auth_protocol_type', 'protocol_type'
value_in_array = %w[native ndmp]
when 'pooltype'
value_in_array = %w[backup archive cloned migration copy save scratch]
when 'label'
value_in_array = %w[ansi ibm bareos]
when 'migration_type'
value_in_array = %w[smallestvolume oldestvolume client volume job sqlquery pooloccupancy pooltime pooluncopiedjobs]
when 'job_type'
value_in_array = %w[backup restore verify admin migrate copy consolidate]
when 'replace_option'
value_in_array = %w[always ifnewer ifolder never]
when 'device_type'
value_in_array = %w[tape file fifo gfapi rados]
when 'compression_algorithm'
value_in_array = %w[gzip lzo lzfast lz4 lz4hc]
else
raise "Invalid setting type '#{type}'"
end
Expand Down
4 changes: 2 additions & 2 deletions manifests/client/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@
}

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

$_require_resource = delete_undef_values([
$_require_res_messages,
Expand Down Expand Up @@ -451,7 +451,7 @@
$_require_res_messages = undef
}

file { "${::bareos::client::config_dir}/${_resource_dir}/${name}.conf":
file { "${::bareos::client::config_dir}/${_resource_dir}/${name_client}.conf":
ensure => $ensure,
mode => $::bareos::file_mode,
owner => $::bareos::file_owner,
Expand Down
2 changes: 1 addition & 1 deletion manifests/client/director.pp
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@
if $ensure == 'present' {
$_settings = bareos_settings(
[$name, 'Name', 'name', true],
[$description, 'Description', 'string', false],
[$address, 'Address', 'string', false],
[$allowed_job_command, 'Allowed Job Command', 'string_list', false],
[$allowed_script_dir, 'Allowed Script Dir', 'directory_list', false],
[$connection_from_client_to_director, 'Connection From Client To Director', 'boolean', false],
[$connection_from_director_to_client, 'Connection From Director To Client', 'boolean', false],
[$description, 'Description', 'string', false],
[$maximum_bandwidth_per_job, 'Maximum Bandwidth Per Job', 'speed', false],
[$monitor, 'Monitor', 'boolean', false],
[$password, 'Password', 'md5password', true],
Expand Down
6 changes: 6 additions & 0 deletions manifests/director.pp
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,10 @@
require => Package[$package_name],
notify => Service[$service_name],
}

File <| |> -> exec { 'bareos director init catalog':
command => '/usr/lib/bareos/scripts/create_bareos_database && /usr/lib/bareos/scripts/make_bareos_tables && /usr/lib/bareos/scripts/grant_bareos_privileges',
notify => Service[$::bareos::director::service_name],
refreshonly => true,
}
}
9 changes: 1 addition & 8 deletions manifests/director/catalog.pp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@
)
}

$_exec_create = "bareos catalog create database ${title}"
file { "${::bareos::director::config_dir}/${_resource_dir}/${name}.conf":
ensure => $ensure,
mode => $::bareos::file_mode,
Expand All @@ -187,13 +186,7 @@
content => template('bareos/resource.erb'),
notify => [
Service[$::bareos::director::service_name],
Exec[$_exec_create],
Exec['bareos director init catalog'],
]
}
# execute after all config files are written
File <| |> -> exec { $_exec_create:
command => '/usr/lib/bareos/scripts/create_bareos_database && /usr/lib/bareos/scripts/make_bareos_tables && /usr/lib/bareos/scripts/grant_bareos_privileges',
notify => Service[$::bareos::director::service_name],
refreshonly => true,
}
}
37 changes: 2 additions & 35 deletions manifests/director/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,6 @@
# Bareos Default: true
# Required: false
#
# [*fd_address*]
# Fd Address: Alias for Address.
#
# Bareos Datatype: string
# Bareos Default: Not set
# Required: false
#
# [*fd_password*]
# Fd Password
#
# Bareos Datatype: autopassword
# Bareos Default: Not set
# Required: false
#
# [*fd_port*]
# Fd Port
#
# Bareos Datatype: pint32
# Bareos Default: 9102
# Required: false
#
# [*file_retention*]
# File Retention
#
Expand Down Expand Up @@ -305,9 +284,6 @@
$connection_from_director_to_client = undef,
$description = undef,
$enabled = undef,
$fd_address = undef,
$fd_password = undef,
$fd_port = undef,
$file_retention = undef,
$hard_quota = undef,
$heartbeat_interval = undef,
Expand Down Expand Up @@ -355,25 +331,16 @@
$_require_res_catalog,
])

unless $auth_type == undef or (downcase($auth_type) in [ 'Clear', 'md5' ]) {
fail('Invalid value for auth_type')
}
unless $protocol == undef or (downcase($protocol) in [ 'native', 'ndmp' ]) {
fail('Invalid value for protocol')
}
$_settings = bareos_settings(
[$name, 'Name', 'name', true],
[$description, 'Description', 'string', false],
[$address, 'Address', 'string', true],
[$auth_type, 'Auth Type', 'type', false],
[$auth_type, 'Auth Type', 'auth_type', false],
[$auto_prune, 'Auto Prune', 'boolean', false],
[$catalog, 'Catalog', 'res', false],
[$connection_from_client_to_director, 'Connection From Client To Director', 'boolean', false],
[$connection_from_director_to_client, 'Connection From Director To Client', 'boolean', false],
[$enabled, 'Enabled', 'boolean', false],
[$fd_address, 'Fd Address', 'string', false],
[$fd_password, 'Fd Password', 'autopassword', false],
[$fd_port, 'Fd Port', 'pint32', false],
[$file_retention, 'File Retention', 'time', false],
[$hard_quota, 'Hard Quota', 'size64', false],
[$heartbeat_interval, 'Heartbeat Interval', 'time', false],
Expand All @@ -386,7 +353,7 @@
[$passive, 'Passive', 'boolean', false],
[$password, 'Password', 'autopassword', true],
[$port, 'Port', 'pint32', false],
[$protocol, 'Protocol', 'type', false],
[$protocol, 'Protocol', 'auth_protocol_type', false],
[$quota_include_failed_jobs, 'Quota Include Failed Jobs', 'boolean', false],
[$soft_quota, 'Soft Quota', 'size64', false],
[$soft_quota_grace_period, 'Soft Quota Grace Period', 'time', false],
Expand Down
9 changes: 9 additions & 0 deletions manifests/director/counter.pp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
}

if $ensure == 'present' {
$_require_res_catalog = $catalog ? { undef => undef, default => Bareos::Director::Catalog[$catalog] }

$_require_resource = delete_undef_values([
$_require_res_catalog,
])

$_settings = bareos_settings(
[$name, 'Name', 'name', true],
[$description, 'Description', 'string', false],
Expand All @@ -67,6 +73,8 @@
[$minimum, 'Minimum', 'int32', false],
[$wrap_counter, 'Wrap Counter', 'res', false]
)
} else {
$_require_resource = undef
}

file { "${::bareos::director::config_dir}/${_resource_dir}/${name}.conf":
Expand All @@ -76,5 +84,6 @@
group => $::bareos::file_group,
content => template('bareos/resource.erb'),
notify => Service[$::bareos::director::service_name],
require => $_require_resource,
}
}
2 changes: 1 addition & 1 deletion manifests/director/director.pp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@
$omit_defaults = undef,
$optimize_for_size = undef,
$optimize_for_speed = undef,
$password = 'set',
$password = 'PleaseChangeMe',
$pid_directory = undef,
$plugin_directory = undef,
$plugin_names = undef,
Expand Down
32 changes: 5 additions & 27 deletions manifests/director/job.pp
Original file line number Diff line number Diff line change
Expand Up @@ -566,13 +566,6 @@
# Bareos Default: Not set
# Required: true
#
# [*verify_job*]
# Verify Job
#
# Bareos Datatype: res
# Bareos Default: Not set
# Required: false
#
# [*virtual_full_backup_pool*]
# Virtual Full Backup Pool
#
Expand Down Expand Up @@ -682,7 +675,6 @@
$storage = undef,
$strip_prefix = undef,
$type = undef,
$verify_job = undef,
$virtual_full_backup_pool = undef,
$where = undef,
$write_bootstrap = undef,
Expand Down Expand Up @@ -711,7 +703,7 @@
$_require_res_client = $client ? { undef => undef, default => Bareos::Director::Client[$client] }
$_require_res_file_set = $file_set ? { undef => undef, default => Bareos::Director::Fileset[$file_set] }
# note: verify_job is an alias to job_to_verify
$_jobs = delete_undef_values([$base, $job_to_verify, $verify_job])
$_jobs = delete_undef_values([$base, $job_to_verify])
$_require_res_jobs = empty($_jobs) ? { false => Bareos::Director::Job[$_jobs], default => undef }
$_require_res_job_defs = $job_defs ? { undef => undef, default => Bareos::Director::Jobdefs[$job_defs] }
$_require_res_message = $messages ? { undef => undef, default => Bareos::Director::Messages[$messages] }
Expand All @@ -733,19 +725,6 @@
$_require_res_storage,
])

unless $level == undef or (downcase($level) in [ 'full', 'incremental', 'differential', 'virtualfull', 'initcatalog', 'catalog', 'volumetocatalog', 'disktocatalog' ]) {
fail("Invalid value for level: ${level}")
}
unless $protocol == undef or (downcase($protocol) in [ 'native', 'ndmp' ]) {
fail('Invalid value for protocol')
}
unless $selection_type == undef or (downcase($selection_type) in [ 'smallestvolume', 'oldestvolume', 'client', 'volume', 'job', 'sqlquery', 'pooloccupancy', 'pooltime', 'pooluncopiedjobs' ]) {
fail('Invalid value for selection_type')
}
unless $type == undef or (downcase($type) in [ 'backup', 'restore', 'verify', 'admin', 'migrate', 'copy', 'consolidate' ]) {
fail("Invalid value for type: ${type}")
}

$_settings = bareos_settings(
[$name, 'Name', 'name', true],
[$description, 'Description', 'string', false],
Expand Down Expand Up @@ -782,7 +761,7 @@
[$incremental_max_runtime, 'Incremental Max Runtime', 'time', false],
[$job_defs, 'Job Defs', 'res', false],
[$job_to_verify, 'Job To Verify', 'res', false],
[$level, 'Level', 'type', false],
[$level, 'Level', 'backup_level', false],
[$max_concurrent_copies, 'Max Concurrent Copies', 'pint32', false],
[$max_diff_interval, 'Max Diff Interval', 'time', false],
[$max_full_consolidations, 'Max Full Consolidations', 'pint32', false],
Expand All @@ -800,7 +779,7 @@
[$prefer_mounted_volumes, 'Prefer Mounted Volumes', 'boolean', false],
[$prefix_links, 'Prefix Links', 'boolean', false],
[$priority, 'Priority', 'pint32', false],
[$protocol, 'Protocol', 'type', false],
[$protocol, 'Protocol', 'protocol_type', false],
[$prune_files, 'Prune Files', 'boolean', false],
[$prune_jobs, 'Prune Jobs', 'boolean', false],
[$prune_volumes, 'Prune Volumes', 'boolean', false],
Expand All @@ -820,14 +799,13 @@
[$schedule_res, 'Schedule', 'res', false],
[$sd_plugin_options, 'Sd Plugin Options', 'string_list', false],
[$selection_pattern, 'Selection Pattern', 'string', false],
[$selection_type, 'Selection Type', 'type', false],
[$selection_type, 'Selection Type', 'migration_type', false],
[$spool_attributes, 'Spool Attributes', 'boolean', false],
[$spool_data, 'Spool Data', 'boolean', false],
[$spool_size, 'Spool Size', 'size64', false],
[$storage, 'Storage', 'resource_list', false],
[$strip_prefix, 'Strip Prefix', 'string', false],
[$type, 'Type', 'type', $_require_res],
[$verify_job, 'Verify Job', 'res', false],
[$type, 'Type', 'job_type', $_require_res],
[$virtual_full_backup_pool, 'Virtual Full Backup Pool', 'res', false],
[$where, 'Where', 'directory', false],
[$write_bootstrap, 'Write Bootstrap', 'directory', false],
Expand Down
Loading

0 comments on commit 1e93248

Please sign in to comment.