From 77c4809b68ba8b872496b5d00846b138d99257ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Fr=C3=B6hner?= Date: Wed, 9 Mar 2022 10:19:40 +0100 Subject: [PATCH] WIP --- .fixtures.yaml | 13 +- Gemfile | 4 + manifests/client.pp | 62 +-- manifests/client/client.pp | 463 ------------------ manifests/client/config.pp | 64 +++ manifests/client/config/director.pp | 20 + manifests/client/config/fd.pp | 24 + manifests/client/{ => config}/messages.pp | 2 +- manifests/client/director.pp | 235 --------- manifests/client/package.pp | 17 + manifests/client/service.pp | 16 + manifests/config.pp | 41 ++ manifests/console.pp | 58 +-- manifests/director.pp | 18 +- manifests/init.pp | 150 +++--- manifests/monitor.pp | 62 +-- manifests/params.pp | 97 +++- manifests/profile/client.pp | 8 +- manifests/repository.pp | 170 ++----- manifests/repository/apt.pp | 50 ++ manifests/repository/yum.pp | 54 ++ manifests/webui.pp | 87 ++-- manifests/webui/director.pp | 57 ++- metadata.json | 3 +- spec/classes/client_client_spec.rb | 96 ---- spec/classes/client_spec.rb | 17 - spec/classes/console_spec.rb | 17 - spec/classes/director_director_spec.rb | 98 ---- spec/classes/director_spec.rb | 53 -- spec/classes/init_spec.rb | 54 +- spec/classes/monitor_spec.rb | 17 - spec/classes/repository_spec.rb | 58 --- spec/classes/storage_spec.rb | 108 ---- spec/classes/storage_storage_spec.rb | 101 ---- spec/classes/webui_spec.rb | 38 -- spec/defines/client/client_director_spec.rb | 77 --- spec/defines/client/client_messages_spec.rb | 65 --- spec/defines/console/console_console_spec.rb | 69 --- spec/defines/console/console_director_spec.rb | 67 --- spec/defines/director/director_catalog.rb | 78 --- spec/defines/director/director_client_spec.rb | 103 ---- .../defines/director/director_console_spec.rb | 92 ---- .../defines/director/director_counter_spec.rb | 64 --- .../defines/director/director_fileset_spec.rb | 51 -- spec/defines/director/director_job_spec.rb | 188 ------- .../defines/director/director_jobdefs_spec.rb | 167 ------- .../director/director_messages_spec.rb | 62 --- spec/defines/director/director_pool_spec.rb | 98 ---- .../defines/director/director_profile_spec.rb | 57 --- .../director/director_schedule_spec.rb | 49 -- .../defines/director/director_storage_spec.rb | 104 ---- spec/defines/monitor/monitor_client_spec.rb | 57 --- spec/defines/monitor/monitor_director_spec.rb | 55 --- spec/defines/monitor/monitor_monitor_spec.rb | 58 --- spec/defines/monitor/monitor_storage_spec.rb | 59 --- .../storage/storage_autochanger_spec.rb | 83 ---- spec/defines/storage/storage_device_spec.rb | 119 ----- spec/defines/storage/storage_director_spec.rb | 76 --- spec/defines/storage/storage_messages_spec.rb | 62 --- spec/defines/storage/storage_ndmp_spec.rb | 66 --- spec/functions/bareos_settings_spec.rb | 444 ----------------- spec/helper/get_defaults.rb | 91 ++++ spec/settings_helper.rb | 117 ----- spec/shared_examples.rb | 14 + spec/shared_examples/client.rb | 17 + spec/shared_examples/client/config.rb | 55 +++ spec/shared_examples/client/package.rb | 25 + spec/shared_examples/client/service.rb | 22 + spec/shared_examples/config.rb | 52 ++ spec/shared_examples/console.rb | 39 ++ spec/shared_examples/monitor.rb | 41 ++ spec/shared_examples/repository.rb | 55 +++ spec/shared_examples/repository/apt.rb | 60 +++ spec/shared_examples/repository/yum.rb | 54 ++ spec/spec_helper.rb | 2 - templates/client/director.conf.epp | 29 ++ templates/client/fd.conf.epp | 52 ++ .../webui_configuration.epp} | 18 +- .../webui_directors.epp} | 20 +- types/acl.pp | 8 + types/actiononpurge.pp | 7 + types/address.pp | 7 + types/addresses.pp | 33 ++ types/auditcommandlist.pp | 16 + types/authprotocaltype.pp | 10 + types/authtype.pp | 9 + types/autopassword.pp | 5 + types/backuplevel.pp | 14 + types/bit.pp | 5 + types/boolean.pp | 13 +- types/client/config.pp | 4 + types/client/config/fd.pp | 55 +++ types/compressionalgorithm.pp | 13 + types/device.pp | 5 + types/devicetype.pp | 12 + types/directory.pp | 5 + types/directorylist.pp | 7 + types/include.pp | 5 + types/list.pp | 2 - types/repository/key.pp | 6 + types/resource.pp | 2 - types/version.pp | 8 + 102 files changed, 1549 insertions(+), 4367 deletions(-) delete mode 100644 manifests/client/client.pp create mode 100644 manifests/client/config.pp create mode 100644 manifests/client/config/director.pp create mode 100644 manifests/client/config/fd.pp rename manifests/client/{ => config}/messages.pp (99%) delete mode 100644 manifests/client/director.pp create mode 100644 manifests/client/package.pp create mode 100644 manifests/client/service.pp create mode 100644 manifests/config.pp create mode 100644 manifests/repository/apt.pp create mode 100644 manifests/repository/yum.pp delete mode 100644 spec/classes/client_client_spec.rb delete mode 100644 spec/classes/client_spec.rb delete mode 100644 spec/classes/console_spec.rb delete mode 100644 spec/classes/director_director_spec.rb delete mode 100644 spec/classes/director_spec.rb delete mode 100644 spec/classes/monitor_spec.rb delete mode 100644 spec/classes/repository_spec.rb delete mode 100644 spec/classes/storage_spec.rb delete mode 100644 spec/classes/storage_storage_spec.rb delete mode 100644 spec/classes/webui_spec.rb delete mode 100644 spec/defines/client/client_director_spec.rb delete mode 100644 spec/defines/client/client_messages_spec.rb delete mode 100644 spec/defines/console/console_console_spec.rb delete mode 100644 spec/defines/console/console_director_spec.rb delete mode 100644 spec/defines/director/director_catalog.rb delete mode 100644 spec/defines/director/director_client_spec.rb delete mode 100644 spec/defines/director/director_console_spec.rb delete mode 100644 spec/defines/director/director_counter_spec.rb delete mode 100644 spec/defines/director/director_fileset_spec.rb delete mode 100644 spec/defines/director/director_job_spec.rb delete mode 100644 spec/defines/director/director_jobdefs_spec.rb delete mode 100644 spec/defines/director/director_messages_spec.rb delete mode 100644 spec/defines/director/director_pool_spec.rb delete mode 100644 spec/defines/director/director_profile_spec.rb delete mode 100644 spec/defines/director/director_schedule_spec.rb delete mode 100644 spec/defines/director/director_storage_spec.rb delete mode 100644 spec/defines/monitor/monitor_client_spec.rb delete mode 100644 spec/defines/monitor/monitor_director_spec.rb delete mode 100644 spec/defines/monitor/monitor_monitor_spec.rb delete mode 100644 spec/defines/monitor/monitor_storage_spec.rb delete mode 100644 spec/defines/storage/storage_autochanger_spec.rb delete mode 100644 spec/defines/storage/storage_device_spec.rb delete mode 100644 spec/defines/storage/storage_director_spec.rb delete mode 100644 spec/defines/storage/storage_messages_spec.rb delete mode 100644 spec/defines/storage/storage_ndmp_spec.rb delete mode 100644 spec/functions/bareos_settings_spec.rb create mode 100644 spec/helper/get_defaults.rb delete mode 100644 spec/settings_helper.rb create mode 100644 spec/shared_examples.rb create mode 100644 spec/shared_examples/client.rb create mode 100644 spec/shared_examples/client/config.rb create mode 100644 spec/shared_examples/client/package.rb create mode 100644 spec/shared_examples/client/service.rb create mode 100644 spec/shared_examples/config.rb create mode 100644 spec/shared_examples/console.rb create mode 100644 spec/shared_examples/monitor.rb create mode 100644 spec/shared_examples/repository.rb create mode 100644 spec/shared_examples/repository/apt.rb create mode 100644 spec/shared_examples/repository/yum.rb create mode 100644 templates/client/director.conf.epp create mode 100644 templates/client/fd.conf.epp rename templates/{webui_configuration.erb => webui/webui_configuration.epp} (50%) rename templates/{webui_directors.erb => webui/webui_directors.epp} (60%) create mode 100644 types/acl.pp create mode 100644 types/actiononpurge.pp create mode 100644 types/address.pp create mode 100644 types/addresses.pp create mode 100644 types/auditcommandlist.pp create mode 100644 types/authprotocaltype.pp create mode 100644 types/authtype.pp create mode 100644 types/autopassword.pp create mode 100644 types/backuplevel.pp create mode 100644 types/bit.pp create mode 100644 types/client/config.pp create mode 100644 types/client/config/fd.pp create mode 100644 types/compressionalgorithm.pp create mode 100644 types/device.pp create mode 100644 types/devicetype.pp create mode 100644 types/directory.pp create mode 100644 types/directorylist.pp create mode 100644 types/include.pp delete mode 100644 types/list.pp create mode 100644 types/repository/key.pp delete mode 100644 types/resource.pp create mode 100644 types/version.pp diff --git a/.fixtures.yaml b/.fixtures.yaml index f08f7be..6950052 100644 --- a/.fixtures.yaml +++ b/.fixtures.yaml @@ -1,8 +1,7 @@ fixtures: - repositories: - concat: https://github.com/puppetlabs/puppetlabs-concat.git - stdlib: https://github.com/puppetlabs/puppetlabs-stdlib.git - apt: https://github.com/puppetlabs/puppetlabs-apt.git - yumrepo_core: - repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git - puppet_version: ">= 6.0.0" + forge_modules: + apt: 'puppetlabs-apt' + stdlib: 'puppetlabs-stdlib' + yumrepo_core: 'puppetlabs-yumrepo_core' + symlinks: + bareos: "#{source_dir}" diff --git a/Gemfile b/Gemfile index 04295a4..7421e10 100644 --- a/Gemfile +++ b/Gemfile @@ -31,4 +31,8 @@ gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false, :groups => [:test] puppetversion = ENV['PUPPET_GEM_VERSION'] || '>= 6.0' gem 'puppet', puppetversion, :require => false, :groups => [:test] +gem 'facterdb' +gem 'parallel_tests' +gem 'rspec-puppet-facts' + # vim: syntax=ruby diff --git a/manifests/client.pp b/manifests/client.pp index 49e842d..f01534b 100644 --- a/manifests/client.pp +++ b/manifests/client.pp @@ -1,54 +1,16 @@ -# == Class: bareos::client -# This class manages the bareos client (file-daemon) service, packages and configuration directory. -# Parameters should be configured in the upper class `::bareos`. - -# This class will be automatically included when a resource is defined. -# It is not intended to be used directly by external resources like node definitions or other modules. +# @summary +# +# @api private +# class bareos::client ( - $manage_service = $bareos::manage_service, - $manage_package = $bareos::manage_package, - $package_name = $bareos::client_package_name, - $package_ensure = $bareos::package_ensure, - $service_name = $bareos::client_service_name, - $service_ensure = $bareos::service_ensure, - $service_enable = $bareos::service_enable, - $config_dir = "${bareos::config_dir}/bareos-fd.d" -) inherits bareos { - include bareos::client::client - - if $manage_package { - package { $package_name: - ensure => $package_ensure, - tag => ['bareos', 'bareos_client'], - } - } - - if $manage_service { - service { $service_name: - ensure => $service_ensure, - enable => $service_enable, - tag => ['bareos', 'bareos_client'], - } - } +) { + assert_private() - # directories - $config_client_dirs = [ - $config_dir, - "${config_dir}/client", - "${config_dir}/director", - "${config_dir}/messages", - ] + contain bareos::client::config + contain bareos::client::package + contain bareos::client::service - file { $config_client_dirs: - ensure => directory, - purge => true, - recurse => true, - force => true, - mode => $bareos::file_dir_mode, - owner => $bareos::file_owner, - group => $bareos::file_group, - require => Package[$package_name], - notify => Service[$service_name], - tag => ['bareos', 'bareos_client'], - } + Class['bareos::client::package'] -> Class['bareos::client::config'] + Class['bareos::client::config'] ~> Class['bareos::client::service'] + Class['bareos::client::package'] ~> Class['bareos::client::service'] } diff --git a/manifests/client/client.pp b/manifests/client/client.pp deleted file mode 100644 index 6254e7a..0000000 --- a/manifests/client/client.pp +++ /dev/null @@ -1,463 +0,0 @@ -# == Class: bareos::client::client -# The Client Resource (or FileDaemon) resource defines the name of the Client (as used by the Director) -# as well as the port on which the Client listens for Director connections. -# -# == Parameters -# [*ensure*] -# present or absent the config file. -# -# [*absolute_job_timeout*] -# Absolute Job Timeout -# -# Bareos Datatype: pint32 -# Bareos Default: Not set -# Required: false -# -# [*allow_bandwidth_bursting*] -# Allow Bandwidth Bursting -# -# Bareos Datatype: boolean -# Bareos Default: false -# Required: false -# -# [*allowed_job_command*] -# Allowed Job Command -# -# May be specified as Array. -# Bareos Datatype: string_list -# Bareos Default: Not set -# Required: false -# -# [*allowed_script_dir*] -# Allowed Script Dir -# -# May be specified as Array. -# Bareos Datatype: directory_list -# Bareos Default: Not set -# Required: false -# -# [*always_use_lmdb*] -# Always Use Lmdb -# -# Bareos Datatype: boolean -# Bareos Default: false -# Required: false -# -# [*compatible*] -# Compatible -# -# Bareos Datatype: boolean -# Bareos Default: false -# Required: false -# -# [*description*] -# Description -# -# Bareos Datatype: string -# Bareos Default: Not set -# Required: false -# -# [*fd_address*] -# Fd Address -# -# Bareos Datatype: address -# Bareos Default: 9102 -# Required: false -# -# [*fd_addresses*] -# Fd Addresses -# -# Bareos Datatype: addresses -# Bareos Default: 9102 -# Required: false -# -# [*fd_port*] -# Fd Port -# -# Bareos Datatype: port -# Bareos Default: 9102 -# Required: false -# -# [*fd_source_address*] -# Fd Source Address -# -# Bareos Datatype: address -# Bareos Default: 0 -# Required: false -# -# [*heartbeat_interval*] -# Heartbeat Interval -# -# Bareos Datatype: time -# Bareos Default: 0 -# Required: false -# -# [*lmdb_threshold*] -# Lmdb Threshold -# -# Bareos Datatype: pint32 -# Bareos Default: Not set -# Required: false -# -# [*log_timestamp_format*] -# Log Timestamp Format -# -# Bareos Datatype: string -# Bareos Default: Not set -# Required: false -# -# [*maximum_bandwidth_per_job*] -# Maximum Bandwidth Per Job -# -# Bareos Datatype: speed -# Bareos Default: Not set -# Required: false -# -# [*maximum_concurrent_jobs*] -# Maximum Concurrent Jobs -# -# Bareos Datatype: pint32 -# Bareos Default: 20 -# Required: false -# -# [*maximum_connections*] -# Maximum Connections -# -# Bareos Datatype: pint32 -# Bareos Default: 42 -# Required: false -# -# [*maximum_network_buffer_size*] -# Maximum Network Buffer Size -# -# Bareos Datatype: pint32 -# Bareos Default: Not set -# Required: false -# -# [*messages*] -# Messages -# -# Bareos Datatype: res -# Bareos Default: Not set -# Required: false -# -# [*name_client*] -# Name of this client. -# Note: name is usually reserved by puppet for resource titles, since this is an class and not and define use name_client. -# -# Bareos Datatype: name -# Bareos Default: Not set -# Required: true -# -# [*pid_directory*] -# Pid Directory -# -# Bareos Datatype: directory -# Bareos Default: /var/lib/bareos -# Required: false -# -# [*pki_cipher*] -# Pki Cipher -# -# Bareos Datatype: encryption_cipher -# Bareos Default: aes128 -# Required: false -# -# [*pki_encryption*] -# Pki Encryption -# -# Bareos Datatype: boolean -# Bareos Default: false -# Required: false -# -# [*pki_key_pair*] -# Pki Key Pair -# -# Bareos Datatype: directory -# Bareos Default: Not set -# Required: false -# -# [*pki_master_key*] -# Pki Master Key -# -# May be specified as Array. -# Bareos Datatype: directory_list -# Bareos Default: Not set -# Required: false -# -# [*pki_signatures*] -# Pki Signatures -# -# Bareos Datatype: boolean -# Bareos Default: false -# Required: false -# -# [*pki_signer*] -# Pki Signer -# -# May be specified as Array. -# Bareos Datatype: directory_list -# Bareos Default: Not set -# Required: false -# -# [*plugin_directory*] -# Plugin Directory -# -# Bareos Datatype: directory -# Bareos Default: Not set -# Required: false -# -# [*plugin_names*] -# Plugin Names -# -# Bareos Datatype: plugin_names -# Bareos Default: Not set -# Required: false -# -# [*scripts_directory*] -# Scripts Directory -# -# Bareos Datatype: directory -# Bareos Default: Not set -# Required: false -# -# [*sd_connect_timeout*] -# Sd Connect Timeout -# -# Bareos Datatype: time -# Bareos Default: 1800 -# Required: false -# -# [*secure_erase_command*] -# Secure Erase Command: Specify command that will be called when bareos unlinks files. -# -# Bareos Datatype: string -# Bareos Default: Not set -# Required: false -# -# [*tls_allowed_cn*] -# Tls Allowed Cn: "Common Name"s (CNs) of the allowed peer certificates. -# -# May be specified as Array. -# Bareos Datatype: string_list -# Bareos Default: Not set -# Required: false -# -# [*tls_authenticate*] -# Tls Authenticate: Use TLS only to authenticate, not for encryption. -# -# Bareos Datatype: boolean -# Bareos Default: false -# Required: false -# -# [*tls_ca_certificate_dir*] -# Tls Ca Certificate Dir: Path of a TLS CA certificate directory. -# -# Bareos Datatype: directory -# Bareos Default: Not set -# Required: false -# -# [*tls_ca_certificate_file*] -# Tls Ca Certificate File: Path of a PEM encoded TLS CA certificate(s) file. -# -# Bareos Datatype: directory -# Bareos Default: Not set -# Required: false -# -# [*tls_certificate*] -# Tls Certificate: Path of a PEM encoded TLS certificate. -# -# Bareos Datatype: directory -# Bareos Default: Not set -# Required: false -# -# [*tls_certificate_revocation_list*] -# Tls Certificate Revocation List: Path of a Certificate Revocation List file. -# -# Bareos Datatype: directory -# Bareos Default: Not set -# Required: false -# -# [*tls_cipher_list*] -# Tls Cipher List: List of valid TLS Ciphers. -# -# Bareos Datatype: string -# Bareos Default: Not set -# Required: false -# -# [*tls_dh_file*] -# Tls Dh File: Path to PEM encoded Diffie-Hellman parameter file. If this directive is specified, DH key exchange will be used for the ephemeral keying, allowing for forward secrecy of communications. -# -# Bareos Datatype: directory -# Bareos Default: Not set -# Required: false -# -# [*tls_enable*] -# Tls Enable: Enable TLS support. -# -# Bareos Datatype: boolean -# Bareos Default: false -# Required: false -# -# [*tls_key*] -# Tls Key: Path of a PEM encoded private key. It must correspond to the specified "TLS Certificate". -# -# Bareos Datatype: directory -# Bareos Default: Not set -# Required: false -# -# [*tls_require*] -# Tls Require: Without setting this to yes, Bareos can fall back to use unencryption connections. Enabling this implicietly sets "TLS Enable = yes". -# -# Bareos Datatype: boolean -# Bareos Default: false -# Required: false -# -# [*tls_verify_peer*] -# Tls Verify Peer: If disabled, all certificates signed by a known CA will be accepted. If enabled, the CN of a certificate must the Address or in the "TLS Allowed CN" list. -# -# Bareos Datatype: boolean -# Bareos Default: true -# Required: false -# -# [*ver_id*] -# Ver Id -# -# Bareos Datatype: string -# Bareos Default: Not set -# Required: false -# -# [*working_directory*] -# Working Directory -# -# Bareos Datatype: directory -# Bareos Default: /var/lib/bareos -# Required: false -# -class bareos::client::client ( - $ensure = present, - $absolute_job_timeout = undef, - $allow_bandwidth_bursting = undef, - $allowed_job_command = undef, - $allowed_script_dir = undef, - $always_use_lmdb = undef, - $compatible = undef, - $description = undef, - $fd_address = undef, - $fd_addresses = undef, - $fd_port = undef, - $fd_source_address = undef, - $heartbeat_interval = undef, - $lmdb_threshold = undef, - $log_timestamp_format = undef, - $maximum_bandwidth_per_job = undef, - $maximum_concurrent_jobs = undef, - $maximum_connections = undef, - $maximum_network_buffer_size = undef, - $messages = undef, - $name_client = 'bareos-fd', - $pid_directory = undef, - $pki_cipher = undef, - $pki_encryption = undef, - $pki_key_pair = undef, - $pki_master_key = undef, - $pki_signatures = undef, - $pki_signer = undef, - $plugin_directory = undef, - $plugin_names = undef, - $scripts_directory = undef, - $sd_connect_timeout = undef, - $secure_erase_command = undef, - $tls_allowed_cn = undef, - $tls_authenticate = undef, - $tls_ca_certificate_dir = undef, - $tls_ca_certificate_file = undef, - $tls_certificate = undef, - $tls_certificate_revocation_list = undef, - $tls_cipher_list = undef, - $tls_dh_file = undef, - $tls_enable = undef, - $tls_key = undef, - $tls_require = undef, - $tls_verify_peer = undef, - $ver_id = undef, - $working_directory = undef, -) { - include bareos::client - - $_resource = 'Client' - $_resource_dir = 'client' - - unless $ensure in ['present', 'absent'] { - fail('Invalid value for ensure') - } - - if $ensure == 'present' { - $_require_res_messages = $messages ? { undef => undef, default => Bareos::Client::Messages[$messages] } - - $_require_resource = delete_undef_values([ - $_require_res_messages, - ]) - - $_settings = bareos_settings( [$name_client, 'Name', 'name', true], - [$description, 'Description', 'string', false], - [$absolute_job_timeout, 'Absolute Job Timeout', 'pint32', false], - [$allow_bandwidth_bursting, 'Allow Bandwidth Bursting', 'boolean', false], - [$allowed_job_command, 'Allowed Job Command', 'string_list', false], - [$allowed_script_dir, 'Allowed Script Dir', 'directory_list', false], - [$always_use_lmdb, 'Always Use Lmdb', 'boolean', false], - [$compatible, 'Compatible', 'boolean', false], - [$fd_address, 'Fd Address', 'address', false], - [$fd_addresses, 'Fd Addresses', 'addresses', false], - [$fd_port, 'Fd Port', 'port', false], - [$fd_source_address, 'Fd Source Address', 'address', false], - [$heartbeat_interval, 'Heartbeat Interval', 'time', false], - [$lmdb_threshold, 'Lmdb Threshold', 'pint32', false], - [$log_timestamp_format, 'Log Timestamp Format', 'string', false], - [$maximum_bandwidth_per_job, 'Maximum Bandwidth Per Job', 'speed', false], - [$maximum_concurrent_jobs, 'Maximum Concurrent Jobs', 'pint32', false], - [$maximum_connections, 'Maximum Connections', 'pint32', false], - [$maximum_network_buffer_size, 'Maximum Network Buffer Size', 'pint32', false], - [$messages, 'Messages', 'res', false], - [$pid_directory, 'Pid Directory', 'directory', false], - [$pki_cipher, 'Pki Cipher', 'encryption_cipher', false], - [$pki_encryption, 'Pki Encryption', 'boolean', false], - [$pki_key_pair, 'Pki Key Pair', 'directory', false], - [$pki_master_key, 'Pki Master Key', 'directory_list', false], - [$pki_signatures, 'Pki Signatures', 'boolean', false], - [$pki_signer, 'Pki Signer', 'directory_list', false], - [$plugin_directory, 'Plugin Directory', 'directory', false], - [$plugin_names, 'Plugin Names', 'plugin_names', false], - [$scripts_directory, 'Scripts Directory', 'directory', false], - [$sd_connect_timeout, 'Sd Connect Timeout', 'time', false], - [$secure_erase_command, 'Secure Erase Command', 'string', false], - [$tls_allowed_cn, 'Tls Allowed Cn', 'string_list', false], - [$tls_authenticate, 'Tls Authenticate', 'boolean', false], - [$tls_ca_certificate_dir, 'Tls Ca Certificate Dir', 'directory', false], - [$tls_ca_certificate_file, 'Tls Ca Certificate File', 'directory', false], - [$tls_certificate, 'Tls Certificate', 'directory', false], - [$tls_certificate_revocation_list, 'Tls Certificate Revocation List', 'directory', false], - [$tls_cipher_list, 'Tls Cipher List', 'string', false], - [$tls_dh_file, 'Tls Dh File', 'directory', false], - [$tls_enable, 'Tls Enable', 'boolean', false], - [$tls_key, 'Tls Key', 'directory', false], - [$tls_require, 'Tls Require', 'boolean', false], - [$tls_verify_peer, 'Tls Verify Peer', 'boolean', false], - [$ver_id, 'Ver Id', 'string', false], - [$working_directory, 'Working Directory', 'directory', false] - ) - } else { - $_require_res_messages = undef - } - - file { "${bareos::client::config_dir}/${_resource_dir}/bareos-fd.conf": - ensure => $ensure, - mode => $bareos::file_mode, - owner => $bareos::file_owner, - group => $bareos::file_group, - content => template('bareos/resource.erb'), - notify => Service[$bareos::client::service_name], - require => $_require_res_messages, - tag => ['bareos', 'bareos_client'], - } -} diff --git a/manifests/client/config.pp b/manifests/client/config.pp new file mode 100644 index 0000000..9ec2943 --- /dev/null +++ b/manifests/client/config.pp @@ -0,0 +1,64 @@ +# @summary +# manage client configs for bareos +# +# @api private +# +class bareos::client::config ( +) { + assert_private() + + $client_config_directory = "${bareos::config_directory}/${bareos::client_config_directory}" + + if $bareos::enable_client { + file { $client_config_directory: + ensure => directory, + force => true, + group => $bareos::config_group, + mode => $bareos::config_directory_mode, + owner => $bareos::config_owner, + purge => true, + recurse => true, + } + + [ + "${client_config_directory}/client", + "${client_config_directory}/director", + "${client_config_directory}/messages", + ].each |$config_directory| { + file { $config_directory: + ensure => directory, + group => $bareos::config_group, + mode => $bareos::config_directory_mode, + owner => $bareos::config_owner, + } + } + + if $bareos::client_config.has_key('director') { + $bareos::client_config['director'].each |$director, $settings| { + bareos::client::config::director { $director: + * => $settings, + } + } + } + + # if $bareos::client_config.has_key('messages') { + # $bareos::client_config['messages'].each |$messages, $settings| { + # bareos::client::config::messages { $messages: + # * => $settings, + # } + # } + # } + + # bareos::client::config::messages { 'Standard': + # description => 'Send relevant messages to the Director.', + # director => 'bareos-dir = all, !skipped, !restored', + # } + } else { + file { $client_config_directory: + ensure => absent, + force => true, + purge => true, + recurse => true, + } + } +} diff --git a/manifests/client/config/director.pp b/manifests/client/config/director.pp new file mode 100644 index 0000000..2079580 --- /dev/null +++ b/manifests/client/config/director.pp @@ -0,0 +1,20 @@ +# @summary +# The Director resource defines the name and password of the Directors that are permitted to contact this Client. +# +# @api private +# +define bareos::client::config::director ( + $config, +) { + assert_private() + + $client_config_directory = "${bareos::config_directory}/${bareos::client_config_directory}" + + file { "${client_config_directory}/director/${title}.conf": + ensure => file, + content => epp('bareos/client/director.conf.epp', $config), + group => $bareos::config_group, + mode => $bareos::config_file_mode, + owner => $bareos::config_owner, + } +} diff --git a/manifests/client/config/fd.pp b/manifests/client/config/fd.pp new file mode 100644 index 0000000..2f4dbfc --- /dev/null +++ b/manifests/client/config/fd.pp @@ -0,0 +1,24 @@ +# @summary +# manage client configs for bareos +# +# @api private +# +class bareos::client::config::fd ( +) { + assert_private() + + $config = $bareos::client_config.has_key('fd') ? { + true => $bareos::client_config['fd'], + default => {}, + } + + $client_config_directory = "${bareos::config_directory}/${bareos::client_config_directory}" + + file { "${client_config_directory}/client/bareos-fd.conf": + ensure => file, + content => epp('bareos/client/fd.conf.epp', $config), + group => $bareos::config_group, + mode => $bareos::config_file_mode, + owner => $bareos::config_owner, + } +} diff --git a/manifests/client/messages.pp b/manifests/client/config/messages.pp similarity index 99% rename from manifests/client/messages.pp rename to manifests/client/config/messages.pp index e577ace..0048c1f 100644 --- a/manifests/client/messages.pp +++ b/manifests/client/config/messages.pp @@ -129,7 +129,7 @@ # Bareos Default: Not set # Required: false # -define bareos::client::messages ( +define bareos::client::config::messages ( $ensure = present, $append = undef, $catalog = undef, diff --git a/manifests/client/director.pp b/manifests/client/director.pp deleted file mode 100644 index 1b18403..0000000 --- a/manifests/client/director.pp +++ /dev/null @@ -1,235 +0,0 @@ -# == Define: bareos::client::director -# The Director resource defines the name and password of the Directors that are permitted to contact this Client. -# -# == Parameters -# [*ensure*] -# present or absent the config file. -# -# [*address*] -# Address: Director Network Address. Only required if "Connection From Client To Director" is enabled. -# -# Bareos Datatype: string -# Bareos Default: Not set -# Required: false -# -# [*allowed_job_command*] -# Allowed Job Command -# -# May be specified as Array. -# Bareos Datatype: string_list -# Bareos Default: Not set -# Required: false -# -# [*allowed_script_dir*] -# Allowed Script Dir -# -# May be specified as Array. -# Bareos Datatype: directory_list -# Bareos Default: Not set -# Required: false -# -# [*connection_from_client_to_director*] -# Connection From Client To Director: Let the Filedaemon initiate network connections to the Director. -# -# Bareos Datatype: boolean -# Bareos Default: false -# Required: false -# -# [*connection_from_director_to_client*] -# Connection From Director To Client: This Client will accept incoming network connection from this Director. -# -# Bareos Datatype: boolean -# Bareos Default: true -# Required: false -# -# [*description*] -# Description -# -# Bareos Datatype: string -# Bareos Default: Not set -# Required: false -# -# [*maximum_bandwidth_per_job*] -# Maximum Bandwidth Per Job -# -# Bareos Datatype: speed -# Bareos Default: Not set -# Required: false -# -# [*monitor*] -# Monitor -# -# Bareos Datatype: boolean -# Bareos Default: false -# Required: false -# -# [*password*] -# Password -# -# Bareos Datatype: md5password -# Bareos Default: Not set -# Required: true -# -# [*port*] -# Port: Director Network Port. Only used if "Connection From Client To Director" is enabled. -# -# Bareos Datatype: pint32 -# Bareos Default: 9101 -# Required: false -# -# [*tls_allowed_cn*] -# Tls Allowed Cn: "Common Name"s (CNs) of the allowed peer certificates. -# -# May be specified as Array. -# Bareos Datatype: string_list -# Bareos Default: Not set -# Required: false -# -# [*tls_authenticate*] -# Tls Authenticate: Use TLS only to authenticate, not for encryption. -# -# Bareos Datatype: boolean -# Bareos Default: false -# Required: false -# -# [*tls_ca_certificate_dir*] -# Tls Ca Certificate Dir: Path of a TLS CA certificate directory. -# -# Bareos Datatype: directory -# Bareos Default: Not set -# Required: false -# -# [*tls_ca_certificate_file*] -# Tls Ca Certificate File: Path of a PEM encoded TLS CA certificate(s) file. -# -# Bareos Datatype: directory -# Bareos Default: Not set -# Required: false -# -# [*tls_certificate*] -# Tls Certificate: Path of a PEM encoded TLS certificate. -# -# Bareos Datatype: directory -# Bareos Default: Not set -# Required: false -# -# [*tls_certificate_revocation_list*] -# Tls Certificate Revocation List: Path of a Certificate Revocation List file. -# -# Bareos Datatype: directory -# Bareos Default: Not set -# Required: false -# -# [*tls_cipher_list*] -# Tls Cipher List: List of valid TLS Ciphers. -# -# Bareos Datatype: string -# Bareos Default: Not set -# Required: false -# -# [*tls_dh_file*] -# Tls Dh File: Path to PEM encoded Diffie-Hellman parameter file. If this directive is specified, DH key exchange will be used for the ephemeral keying, allowing for forward secrecy of communications. -# -# Bareos Datatype: directory -# Bareos Default: Not set -# Required: false -# -# [*tls_enable*] -# Tls Enable: Enable TLS support. -# -# Bareos Datatype: boolean -# Bareos Default: false -# Required: false -# -# [*tls_key*] -# Tls Key: Path of a PEM encoded private key. It must correspond to the specified "TLS Certificate". -# -# Bareos Datatype: directory -# Bareos Default: Not set -# Required: false -# -# [*tls_require*] -# Tls Require: Without setting this to yes, Bareos can fall back to use unencryption connections. Enabling this implicietly sets "TLS Enable = yes". -# -# Bareos Datatype: boolean -# Bareos Default: false -# Required: false -# -# [*tls_verify_peer*] -# Tls Verify Peer: If disabled, all certificates signed by a known CA will be accepted. If enabled, the CN of a certificate must the Address or in the "TLS Allowed CN" list. -# -# Bareos Datatype: boolean -# Bareos Default: true -# Required: false -# -define bareos::client::director ( - $ensure = present, - $address = undef, - $allowed_job_command = undef, - $allowed_script_dir = undef, - $connection_from_client_to_director = undef, - $connection_from_director_to_client = undef, - $description = undef, - $maximum_bandwidth_per_job = undef, - $monitor = undef, - $password = undef, - $port = undef, - $tls_allowed_cn = undef, - $tls_authenticate = undef, - $tls_ca_certificate_dir = undef, - $tls_ca_certificate_file = undef, - $tls_certificate = undef, - $tls_certificate_revocation_list = undef, - $tls_cipher_list = undef, - $tls_dh_file = undef, - $tls_enable = undef, - $tls_key = undef, - $tls_require = undef, - $tls_verify_peer = undef, -) { - include bareos::client - - $_resource = 'Director' - $_resource_dir = 'director' - - unless $ensure in ['present', 'absent'] { - fail('Invalid value for ensure') - } - - 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], - [$maximum_bandwidth_per_job, 'Maximum Bandwidth Per Job', 'speed', false], - [$monitor, 'Monitor', 'boolean', false], - [$password, 'Password', 'md5password', true], - [$port, 'Port', 'pint32', false], - [$tls_allowed_cn, 'Tls Allowed Cn', 'string_list', false], - [$tls_authenticate, 'Tls Authenticate', 'boolean', false], - [$tls_ca_certificate_dir, 'Tls Ca Certificate Dir', 'directory', false], - [$tls_ca_certificate_file, 'Tls Ca Certificate File', 'directory', false], - [$tls_certificate, 'Tls Certificate', 'directory', false], - [$tls_certificate_revocation_list, 'Tls Certificate Revocation List', 'directory', false], - [$tls_cipher_list, 'Tls Cipher List', 'string', false], - [$tls_dh_file, 'Tls Dh File', 'directory', false], - [$tls_enable, 'Tls Enable', 'boolean', false], - [$tls_key, 'Tls Key', 'directory', false], - [$tls_require, 'Tls Require', 'boolean', false], - [$tls_verify_peer, 'Tls Verify Peer', 'boolean', false] - ) - } - - file { "${bareos::client::config_dir}/${_resource_dir}/${name}.conf": - ensure => $ensure, - mode => $bareos::file_mode, - owner => $bareos::file_owner, - group => $bareos::file_group, - content => template('bareos/resource.erb'), - notify => Service[$bareos::client::service_name], - tag => ['bareos', 'bareos_client'], - } -} diff --git a/manifests/client/package.pp b/manifests/client/package.pp new file mode 100644 index 0000000..84c9480 --- /dev/null +++ b/manifests/client/package.pp @@ -0,0 +1,17 @@ +# @summary +# manage client packages for bareos +# +# @api private +# +class bareos::client::package ( +) { + assert_private() + + if $bareos::enable_client and $bareos::manage_client_package { + $bareos::client_packages.each |$client_package| { + package { $client_package: + ensure => $bareos::client_package_ensure, + } + } + } +} diff --git a/manifests/client/service.pp b/manifests/client/service.pp new file mode 100644 index 0000000..83e4aea --- /dev/null +++ b/manifests/client/service.pp @@ -0,0 +1,16 @@ +# @summary +# manage client service for bareos +# +# @api private +# +class bareos::client::service ( +) { + assert_private() + + if $bareos::enable_client and $bareos::manage_client_service { + service { $bareos::client_service_name: + ensure => $bareos::client_service_ensure, + enable => $bareos::client_service_enable, + } + } +} diff --git a/manifests/config.pp b/manifests/config.pp new file mode 100644 index 0000000..784f5aa --- /dev/null +++ b/manifests/config.pp @@ -0,0 +1,41 @@ +# @summary +# +# @api private +# +class bareos::config ( +) { + assert_private() + + if $bareos::manage_user { + group { $bareos::config_group: + ensure => present, + forcelocal => true, + system => true, + } + + user { $bareos::config_owner: + ensure => present, + comment => 'Bareos system user', + forcelocal => true, + home => '/var/lib/bareos', + shell => '/bin/false', + groups => [ + 'disk', + 'tape', + $bareos::config_group, + ], + system => true, + } + } + + file { $bareos::config_directory: + ensure => directory, + force => true, + group => $bareos::config_group, + mode => $bareos::config_directory_mode, + owner => $bareos::config_owner, + purge => true, + recurse => true, + recurselimit => 1, + } +} diff --git a/manifests/console.pp b/manifests/console.pp index d5507fa..7ce09ce 100644 --- a/manifests/console.pp +++ b/manifests/console.pp @@ -1,38 +1,38 @@ -# == Class: bareos::console -# This class manages the bareos console (bconsole cli tool) package and configuration directory. -# Parameters should be configured in the upper class `::bareos`. +# @summary bareos::console +# +# @api private # -# This class will be automatically included when a resource is defined. -# It is not intended to be used directly by external resources like node definitions or other modules. class bareos::console ( - $manage_package = $bareos::manage_package, - $package_name = $bareos::console_package_name, - $package_ensure = $bareos::package_ensure, - $config_dir = "${bareos::config_dir}/bconsole.d" -) inherits bareos { - if $manage_package { - package { $package_name: - ensure => $package_ensure, - tag => ['bareos', 'bareos_console'], +) { + assert_private() + + if $bareos::manage_console_package { + $bareos::console_packages.each |$console_package| { + package { $console_package: + ensure => $bareos::console_package_ensure, + tag => [ 'bareos', 'bareos_console', ], + } } } - # directories - $config_console_dirs = [ - $config_dir, - "${config_dir}/console", - "${config_dir}/director", + $config_console_directories = [ + "${bareos::config_directory}/bconsole.d", + "${bareos::config_directory}/bconsole.d/console", + "${bareos::config_directory}/bconsole.d/director", ] - file { $config_console_dirs: - ensure => directory, - purge => true, - recurse => true, - force => true, - mode => $bareos::file_dir_mode, - owner => $bareos::file_owner, - group => $bareos::file_group, - require => Package[$package_name], - tag => ['bareos', 'bareos_console'], + $config_console_directories.each | $config_console_directory | { + file { $config_console_directory: + ensure => directory, + purge => true, + recurse => true, + force => true, + mode => $bareos::config_directory_mode, + owner => $bareos::config_owner, + group => $bareos::config_group, + tag => [ 'bareos', 'bareos_console', ], + } } + + Package<| tag == 'bareos_console' |> -> File<| tag == 'bareos_console' |> } diff --git a/manifests/director.pp b/manifests/director.pp index 02ed04c..a5e25d1 100644 --- a/manifests/director.pp +++ b/manifests/director.pp @@ -5,16 +5,16 @@ # This class will be automatically included when a resource is defined. # It is not intended to be used directly by external resources like node definitions or other modules. class bareos::director ( - $manage_service = $bareos::manage_service, - $manage_package = $bareos::manage_package, + $manage_service = $bareos::manage_director_service, + $manage_package = $bareos::manage_director_package, $manage_database = $bareos::manage_database, - $package_name = $bareos::director_package_name, - $package_ensure = $bareos::package_ensure, - $service_name = $bareos::director_service_name, - $service_allow_restart = $bareos::director_service_allow_restart, - $service_ensure = $bareos::service_ensure, - $service_enable = $bareos::service_enable, - $config_dir = "${bareos::config_dir}/bareos-dir.d", + $package_name = $bareos::director_package, + $package_ensure = $bareos::director_package_ensure, + $service_name = $bareos::director_service, + $service_allow_restart = $bareos::director_service_restart, + $service_ensure = $bareos::director_service_ensure, + $service_enable = $bareos::director_service_enable, + $config_dir = "${bareos::config_directory}/bareos-dir.d", Array[String] $managed_dirs = $bareos::director_managed_dirs, Hash $catalogs = {}, Hash $clients = {}, diff --git a/manifests/init.pp b/manifests/init.pp index dd85ab2..4f41ea78 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -32,80 +32,88 @@ # Whether puppet is allowed to restart the director service. If not it will reload # class bareos ( - $config_dir = $bareos::params::config_dir, - $config_dir_webui = $bareos::params::config_dir_webui, - $file_owner = $bareos::params::file_owner, - $file_group = $bareos::params::file_group, - $file_mode = $bareos::params::file_mode, - $file_dir_mode = $bareos::params::file_dir_mode, - String $repo_release = '20', - Boolean $repo_subscription = false, - Optional[String[1]] $repo_username = undef, - Optional[String[1]] $repo_password = undef, - Boolean $manage_package = true, - Boolean $manage_service = true, - Boolean $manage_database = true, - String $package_ensure = present, - String $service_ensure = running, - Boolean $service_enable = true, - Boolean $manage_repo = true, - Boolean $manage_user = true, - String $package_name = 'bareos-common', + ## + ## basic settings + ## + $config_directory = '/etc/bareos', + $config_directory_mode = '0755', + $config_file_mode = '0660', + $config_group = 'bareos', + $config_owner = 'bareos', + $manage_user = true, - $console_package_name = $bareos::params::console_package_name, - $monitor_package_name = $bareos::params::monitor_package_name, - $director_package_name = $bareos::params::director_package_name, - $director_service_name = $bareos::params::director_service_name, - $director_service_allow_restart = false, - $director_managed_dirs = $bareos::params::director_managed_dirs, - $client_package_name = $bareos::params::client_package_name, - $client_service_name = $bareos::params::client_service_name, - $storage_package_name = $bareos::params::storage_package_name, - $storage_service_name = $bareos::params::storage_service_name, -) inherits bareos::params { - if $manage_repo { - class { 'bareos::repository': - release => $repo_release, - subscription => $repo_subscription, - username => $repo_username, - password => $repo_password, - } - } - if $manage_package { - package { $package_name: - ensure => $package_ensure, - tag => ['bareos', 'bareos_core'], - } - } + ## + ## repository settings + ## + Boolean $manage_repository = true, + Optional[Stdlib::Host] $repository_host = undef, + Optional[Hash] $repository_key = {}, + Optional[String[1]] $repository_password = undef, + Bareos::Version $repository_release = '20', + Boolean $repository_ssl = true, + Boolean $repository_subscription = false, + Optional[String[1]] $repository_username = undef, - if $manage_user { - group { $file_group: - ensure => present, - forcelocal => true, - system => true, - tag => ['bareos', 'bareos_core'], - } - -> user { $file_owner: - ensure => present, - forcelocal => true, - comment => 'Bareos system user', - home => '/var/lib/bareos', - shell => '/bin/false', - groups => ['disk', 'tape', $file_group], - system => true, - tag => ['bareos', 'bareos_core'], - } - } + ## + ## client settings + ## + Boolean $enable_client = true, + Boolean $manage_client_package = true, + Boolean $manage_client_service = true, + Hash $client_config = {}, + String[1] $client_config_directory = $bareos::params::client_config_directory, + Array[String[1]] $client_packages = $bareos::params::client_packages, + String[1] $client_package_ensure = $bareos::params::client_package_ensure, + Boolean $client_service_enable = $bareos::params::client_service_enable, + String[1] $client_service_ensure = $bareos::params::client_service_ensure, + String[1] $client_service = $bareos::params::client_service, + + ## + ## console + ## + Boolean $manage_console_package = true, + Array[String[1]] $console_packages = $bareos::params::console_packages, + String[1] $console_package_ensure = $bareos::params::console_package_ensure, + + ## + ## monitor + ## + Boolean $manage_monitor_package = true, + Array[String[1]] $monitor_packages = $bareos::params::monitor_packages, + String[1] $monitor_package_ensure = $bareos::params::monitor_package_ensure, + + ## + ## webui + ## + Boolean $manage_webui_package = $bareos::params::manage_webui_package, + Array[String[1]] $webui_packages = $bareos::params::webui_packages, + String[1] $webui_package_ensure = $bareos::params::webui_package_ensure, - file { $config_dir: - ensure => directory, - purge => true, - recurse => true, - recurselimit => 1, - mode => $bareos::file_dir_mode, - owner => $bareos::file_owner, - group => $bareos::file_group, - tag => ['bareos', 'bareos_core'], + Boolean $manage_webui_service = $bareos::params::manage_webui_service, + String[1] $webui_service = $bareos::params::webui_service, + Boolean $webui_service_enable = $bareos::params::webui_service_enable, + String[1] $webui_service_ensure = $bareos::params::webui_service_ensure, + + String[1] $webui_config_directory = $bareos::params::webui_config_directory, + + + Boolean $webui_manage_local_director = $bareos::params::webui_manage_local_director, + Integer $webui_session_timeout = $bareos::params::webui_session_timeout, + String[1] $webui_pagination_values = $bareos::params::webui_pagination_values, + Integer $webui_pagination_default_value = $bareos::params::webui_pagination_default_value, + Boolean $webui_save_previous_state = $bareos::params::webui_save_previous_state, + String $webui_label_pooltype = $bareos::params::webui_label_pooltype, + Hash $webui_directors = $bareos::params::webui_directors, +) inherits bareos::params { + if $manage_repository { + contain bareos::repository + + Class['bareos::repository'] -> Class['bareos::client'] } + + contain bareos::client + contain bareos::config + contain bareos::console + contain bareos::monitor } diff --git a/manifests/monitor.pp b/manifests/monitor.pp index a1a967d..a0c6886 100644 --- a/manifests/monitor.pp +++ b/manifests/monitor.pp @@ -1,40 +1,40 @@ -# == Class: bareos::monitor -# This class manages the bareos (tray-) monitor package and configuration directory. -# Parameters should be configured in the upper class `::bareos`. +# @summary +# This class manages the bareos (tray-) monitor package and configuration directory. +# Parameters should be configured in the upper class `::bareos`. +# +# @api private # -# This class will be automatically included when a resource is defined. -# It is not intended to be used directly by external resources like node definitions or other modules. class bareos::monitor ( - $manage_package = $bareos::manage_package, - $package_name = $bareos::monitor_package_name, - $package_ensure = $bareos::package_ensure, - $config_dir = "${bareos::config_dir}/tray-monitor.d" -) inherits bareos { - if $manage_package { - package { $package_name: - ensure => $package_ensure, - tag => ['bareos', 'bareos_monitor'], +) { + assert_private() + + if $bareos::manage_monitor_package { + $bareos::monitor_packages.each |$monitor_package| { + package { $monitor_package: + ensure => $bareos::monitor_package_ensure, + tag => [ 'bareos', 'bareos_monitor', ], + } } } - # directories - $config_monitor_dirs = [ - $config_dir, - "${config_dir}/client", - "${config_dir}/director", - "${config_dir}/monitor", - "${config_dir}/storage", + $config_monitor_directories = [ + "${bareos::config_directory}/tray-monitor.d", + "${bareos::config_directory}/tray-monitor.d/client", + "${bareos::config_directory}/tray-monitor.d/director", + "${bareos::config_directory}/tray-monitor.d/monitor", + "${bareos::config_directory}/tray-monitor.d/storage", ] - file { $config_monitor_dirs: - ensure => directory, - purge => true, - recurse => true, - force => true, - mode => $bareos::file_dir_mode, - owner => $bareos::file_owner, - group => $bareos::file_group, - require => Package[$package_name], - tag => ['bareos', 'bareos_monitor'], + $config_monitor_directories.each |$config_monitor_directory| { + file { $config_monitor_directory: + ensure => directory, + purge => true, + recurse => true, + force => true, + mode => $bareos::config_directory_mode, + owner => $bareos::config_owner, + group => $bareos::config_group, + tag => [ 'bareos', 'bareos_monitor', ], + } } } diff --git a/manifests/params.pp b/manifests/params.pp index b8175e2..79ce50a 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,22 +1,12 @@ -# == Class: bareos::params +# @summary +# define default values # class bareos::params { - $file_mode = '0660' - $file_dir_mode = '0755' - $file_owner = 'bareos' - $file_group = 'bareos' - $config_dir = '/etc/bareos' - $config_dir_webui = '/etc/bareos-webui' - - # service/package specific - # bconsole - $console_package_name = 'bareos-bconsole' - - # monitor - $monitor_package_name = 'bareos-traymonitor' - - # director - $director_package_name = [ + ## + ## director + ## + $director_service_name = 'bareos-dir' + $director_packages = [ 'bareos-director', 'bareos-director-python-plugin', 'bareos-database-common', @@ -25,8 +15,8 @@ 'bareos-database-sqlite3', 'bareos-database-tools', ] - $director_service_name = 'bareos-dir' - $director_managed_dirs = ['catalog', + $director_managed_dirs = [ + 'catalog', 'client', 'console', 'counter', @@ -41,15 +31,68 @@ 'storage', ] - # filedaemon/client - $client_package_name = ['bareos-filedaemon', 'bareos-filedaemon-python-plugin'] - $client_service_name = 'bareos-fd' + ## + ## filedaemon/client + ## + $client_config_directory = "bareos-fd.d" + $client_packages = [ + 'bareos-filedaemon', + 'bareos-filedaemon-python-plugin', + ] + $client_package_ensure = present + $client_service_enable = true + $client_service_ensure = running + $client_service_name = 'bareos-fd' - # storage - $storage_package_name = ['bareos-storage', 'bareos-storage-python-plugin', 'bareos-tools'] + ## + ## storage + ## $storage_service_name = 'bareos-sd' + $storage_packages = [ + 'bareos-storage', + 'bareos-storage-python-plugin', + 'bareos-tools', + ] + + ## + ## console + ## + $console_packages = [ + 'bareos-bconsole', + ] + $console_package_ensure = present + + ## + ## monitor + ## + $monitor_packages = [ + 'bareos-traymonitor', + ] + $monitor_package_ensure = present + + + ## + ## webui + ## + $manage_webui_package = true + $webui_package_ensure = present + $webui_packages = [ + 'bareos-webui', + ] + + + $manage_webui_service = true + $webui_service = 'apache2' + $webui_service_enable = true + $webui_service_ensure = running + + $webui_config_directory = '/etc/bareos-webui' - # webui - $webui_package_name = 'bareos-webui' - $webui_service_name = 'apache2' + $webui_manage_local_director = true + $webui_session_timeout = 3600 + $webui_pagination_values = '10,25,50,100' + $webui_pagination_default_value = 25 + $webui_save_previous_state = false + $webui_label_pooltype = '' + $webui_directors = {} } diff --git a/manifests/profile/client.pp b/manifests/profile/client.pp index 134bf51..0c1a765 100644 --- a/manifests/profile/client.pp +++ b/manifests/profile/client.pp @@ -2,8 +2,8 @@ # setup an simple bareos filedaemon/client class bareos::profile::client ( $name_client = $facts['networking']['fqdn'], - $name_dir = 'bareos-dir', - $password = 'MyClientPasswordPleaseChange', + $name_dir = 'bareos-dir', + $password = 'MyClientPasswordPleaseChange', ) { # default client class { 'bareos::client::client': @@ -11,11 +11,11 @@ } # allow bareos server to connect - ::bareos::client::director { $name_dir: + bareos::client::director { $name_dir: password => $password, } - ::bareos::client::messages { 'Standard': + bareos::client::messages { 'Standard': description => 'Send relevant messages to the Director.', director => 'bareos-dir = all, !skipped, !restored', } diff --git a/manifests/repository.pp b/manifests/repository.pp index 8750f55..3717ecb 100644 --- a/manifests/repository.pp +++ b/manifests/repository.pp @@ -1,156 +1,64 @@ -# == Class: bareos::repository -# # @summary # This class manages the bareos repository -# Parameters should be configured in the upper class `::bareos`. +# Parameters should be configured in the upper class `bareos`. # # This class will be automatically included when a resource is defined. # It is not intended to be used directly by external resources like node definitions or other modules. # -# @param release -# The major bareos release version which should be used -# @param gpg_key_fingerprint -# The GPG fingerprint of the repos key -# @param subscription -# Activate the (paid) subscription repo. Otherwise the opensource repos will be selected -# @param username -# The major bareos release version which should be used -# @param password -# The major bareos release version which should be used +# @api private # class bareos::repository ( - Enum['18.2', '19.2', '20', '21'] $release = '20', - Optional[String[1]] $gpg_key_fingerprint = undef, - Boolean $subscription = false, - Optional[String] $username = undef, - Optional[String] $password = undef, ) { - $scheme = 'http://' - if $subscription { - if empty($username) or empty($password) { - fail('For Bareos subscription repos both username and password are required.') - } - # note the .com - $address = "download.bareos.com/bareos/release/${release}/" - } else { - $address = "download.bareos.org/bareos/release/${release}/" + assert_private() + + $schema = $bareos::repository_ssl ? { + true => 'https', + default => 'http', } - $os = $facts['os']['name'] - $osrelease = $facts['os']['release']['full'] - $osmajrelease = $facts['os']['release']['major'] + if $bareos::repository_subscription { + if ! $bareos::repository_username or ! $bareos::repository_password { + fail('You require a username (bareos::repository_username) and password (bareos::repository_password) for Bareos subscription repos.') + } - if $gpg_key_fingerprint { - $_gpg_key_fingerprint = $gpg_key_fingerprint - } elsif versioncmp($release, '21') >= 0 { - # >= bareos 21 - $_gpg_key_fingerprint = '91DA 1DC3 564A E20A 76C4 CA88 E019 57D6 C9FE D482' - } elsif versioncmp($release, '20') >= 0 { - # >= bareos 20 - $_gpg_key_fingerprint = 'C68B 001F 74D2 F202 43D0 B7A2 0CCB A537 DBE0 83A6' + $host = $bareos::repository_host ? { + undef => 'download.bareos.com', + default => $bareos::repository_host + } } else { - # >= bareos-18.2 - if $subscription { - $_gpg_key_fingerprint = '641A 1497 F1B1 1BEA 945F 840F E5D8 82B2 8657 AE28' - } else { - $_gpg_key_fingerprint = 'A0CF E15F 71F7 9857 4AB3 63DD 1182 83D9 A786 2CEE' + $host = $bareos::repository_host ? { + undef => 'download.bareos.org', + default => $bareos::repository_host } } - $yum_username = $username ? { - undef => 'absent', - default => $username, - } - $yum_password = $password ? { - undef => 'absent', - default => $password, - } + $address = "${schema}://${host}/bareos/release/${bareos::repository_release}" - case $os { - /(?i:redhat|centos|rocky|almalinux|fedora|virtuozzolinux|amazon)/: { - $url = "${scheme}${address}" - case $os { - 'RedHat', 'VirtuozzoLinux': { - $location = "${url}RHEL_${osmajrelease}" - } - 'Centos', 'Rocky', 'AlmaLinux': { - if versioncmp($release, '21') >= 0 { - $location = "${url}EL_${osmajrelease}" - } else { - $location = "${url}CentOS_${osmajrelease}" - } - } - 'Fedora': { - $location = "${url}Fedora_${osmajrelease}" - } - 'Amazon': { - case $osmajrelease { - '2': { - $location = "${url}RHEL_7" - } - default: { - fail('Operatingsystem is not supported by this module') - } - } - } - default: { - fail('Operatingsystem is not supported by this module') - } - } - yumrepo { 'bareos': - name => 'bareos', - descr => 'Bareos Repository', - username => $yum_username, - password => $yum_password, - baseurl => $location, - gpgcheck => '1', - gpgkey => "${location}/repodata/repomd.xml.key", - priority => '1', - } - } - /(?i:debian|ubuntu)/: { - if $subscription { - $url = "${scheme}${username}:${password}@${address}" + case $bareos::repository_release { + '18.2', '19.2': { + if $bareos::repository_subscription { + $key_id = '641A1497F1B11BEA945F840FE5D882B28657AE28' } else { - $url = "${scheme}${address}" - } - if $os == 'Ubuntu' { - unless $osrelease in ['12.04', '14.04', '16.04', '18.04', '20.04'] { - fail('Only Ubunutu LTS Versions are supported') - } - $location = "${url}xUbuntu_${osrelease}" - } else { - if $osmajrelease == '10' { - $location = "${url}Debian_${osmajrelease}" - } else { - $location = "${url}Debian_${osmajrelease}.0" - } - } - if $subscription { - # release key file is not avaiable without login and - # apt-key cannot handle username and password in URI - $key = { - id => regsubst($_gpg_key_fingerprint, ' ', '', 'G'), - } - } else { - $key = { - id => regsubst($_gpg_key_fingerprint, ' ', '', 'G'), - source => "${location}/Release.key", - } + $key_id = 'A0CFE15F71F798574AB363DD118283D9A7862CEE' } + } + '20': { + $key_id = 'C68B001F74D2F20243D0B7A20CCBA537DBE083A6' + } + '21': { + $key_id = '91DA1DC3564AE20A76C4CA88E01957D6C9FED482' + } + } - include apt - ::apt::source { 'bareos': - location => $location, - release => '/', - repos => '', - key => $key, - } - Apt::Source['bareos'] -> Package<|tag == 'bareos'|> - Class['Apt::Update'] -> Package<|tag == 'bareos'|> + case $facts['os']['family'] { + 'Debian': { + contain bareos::repository::apt + } + 'RedHat': { + contain bareos::repository::yum } default: { - fail('Operatingsystem is not supported by this module') + fail("Your OS family ${facts['os']['family']} is not supported by ${class_name}. Consider to use bareos::manage_repo: false") } } } diff --git a/manifests/repository/apt.pp b/manifests/repository/apt.pp new file mode 100644 index 0000000..ba8ed3c --- /dev/null +++ b/manifests/repository/apt.pp @@ -0,0 +1,50 @@ +# @summary +# manage apt repository for different OSes +# +# @api private +# +class bareos::repository::apt ( +) { + assert_private() + + include apt + + $address = $bareos::repository::address + + if $bareos::repository_subscription { + file { '/etc/apt/auth.conf.d/bareos': + ensure => 'present', + owner => 'root', + group => 'root', + mode => '0600', + content => Sensitive("machine ${address} login ${bareos::repository_username} password ${bareos::repository_password}"), + notify => Class['apt::update'], + } + } else { + file { '/etc/apt/auth.conf.d/bareos': + ensure => 'absent', + notify => Class['apt::update'], + } + } + + $location = $facts['os']['name'] ? { + 'Debian' => $facts['os']['release']['major'] ? { + '10' => "${address}/Debian_${facts['os']['release']['major']}", + default => "${address}/Debian_${facts['os']['release']['major']}.0", + }, + 'Ubuntu' => "${address}/xUbuntu_${facts['os']['release']['major']}.0", + } + + $key = { + id => $bareos::repository::key_id, + source => "${address}/Release.key", + }.merge($bareos::repository_key) + + apt::source { 'bareos': + location => $location, + release => '/', + repos => '', + key => $key, + notify => Class['apt::update'], + } +} diff --git a/manifests/repository/yum.pp b/manifests/repository/yum.pp new file mode 100644 index 0000000..c1219cd --- /dev/null +++ b/manifests/repository/yum.pp @@ -0,0 +1,54 @@ +# @summary +# manage yum repository for different OSes +# +# @api private +# +class bareos::repository::yum ( +) { + assert_private() + + $address = $bareos::repository::address + + case $facts['os']['name'] { + 'RedHat', 'VirtuozzoLinux': { + $location = "${address}/RHEL_${facts['os']['release']['major']}" + } + 'CentOS', 'Rocky', 'AlmaLinux': { + if $bareos::repository_release == '21' { + $location = "${address}/EL_${facts['os']['release']['major']}" + } else { + $location = "${address}/CentOS_${facts['os']['release']['major']}" + } + } + 'Fedora': { + $location = "${address}/Fedora_${facts['os']['release']['major']}" + } + 'Amazon': { + case $facts['os']['release']['major'] { + '2': { + $location = "${address}/RHEL_7" + } + } + } + } + + $yum_username = $bareos::repository_username ? { + undef => 'absent', + default => $bareos::repository_username, + } + + $yum_password = $bareos::repository_password ? { + undef => 'absent', + default => $bareos::repository_password, + } + + yumrepo { 'bareos': + descr => 'Bareos Repository', + username => $yum_username, + password => $yum_password, + baseurl => $location, + gpgcheck => '1', + gpgkey => "${location}/repodata/repomd.xml.key", + priority => '1', + } +} diff --git a/manifests/webui.pp b/manifests/webui.pp index d7be415..c4cab4c 100644 --- a/manifests/webui.pp +++ b/manifests/webui.pp @@ -1,42 +1,33 @@ -# == Class: bareos::webui -# This class manages the bareos webui service, package and configuration. +# @summary +# This class manages the bareos webui service, package and configuration. +# +# @api private # -# This class will be automatically included when a resource is defined. class bareos::webui ( - $manage_service = $bareos::manage_service, - $manage_package = $bareos::manage_package, - $package_name = $bareos::webui_package_name, - $package_ensure = $bareos::package_ensure, - $service_name = $bareos::webui_service_name, - $service_ensure = $bareos::service_ensure, - $service_enable = $bareos::service_enable, - $config_dir = $bareos::config_dir_webui, +) { + assert_private() + + if $bareos::manage_webui_package { + $bareos::webui_packages.each |$webui_package| { + package { $webui_package: + ensure => $webui_package_ensure, + tag => [ 'bareos', 'bareos_webui', ], + } - $manage_local_dir = true, # setup local bareos director - $session_timeout = 3600, - $pagination_values = '10,25,50,100', - $pagination_default_value = 25, - $save_previous_state = false, - $label_pooltype = '', - $directors = {}, -) inherits bareos { - if $manage_package { - package { $package_name: - ensure => $package_ensure, - tag => ['bareos', 'bareos_webui'], + Package[$webui_package] -> File[$webui_config_directory] } } - if $manage_service { - service { $service_name: - ensure => $service_ensure, - enable => $service_enable, - tag => ['bareos', 'bareos_webui'], + if $bareos::manage_webui_service { + service { $bareos::webui_service: + ensure => $bareos::webui_service_ensure, + enable => $bareos::webui_service_enable, + tag => [ 'bareos', 'bareos_webui', ], + subscribe => File["${bareos::webui_config_directory}/configuration.ini"], } } - # directories - file { $config_dir: + file { $bareos::webui_config_directory: ensure => directory, purge => true, recurse => true, @@ -44,33 +35,35 @@ mode => '0644', owner => 'root', group => 'root', - require => Package[$package_name], - tag => ['bareos', 'bareos_webui'], + tag => [ 'bareos', 'bareos_webui', ], + } + + $configuration = { + 'session_timeout' => $bareos::webui_session_timeout, + 'pagination_values' => $bareos::webui_pagination_values, + 'pagination_default_value' => $bareos::webui_pagination_default_value, + 'save_previous_state' => $bareos::webui_save_previous_state, + 'label_pooltype' => $bareos::webui_label_pooltype, } - file { "${bareos::webui::config_dir}/configuration.ini": + file { "${bareos::webui_config_directory}/configuration.ini": ensure => file, mode => '0644', owner => 'root', group => 'root', - content => template('bareos/webui_configuration.erb'), - notify => Service[$bareos::webui::service_name], - tag => ['bareos', 'bareos_webui'], + content => epp('bareos/webui/webui_configuration.erb', $configuration), + tag => [ 'bareos', 'bareos_webui', ], } - concat { "${bareos::webui::config_dir}/directors.ini": - ensure => present, - mode => '0644', - owner => 'root', - group => 'root', - tag => ['bareos', 'bareos_webui'], - } - - if $manage_local_dir { + if $bareos::webui_manage_local_director { bareos::webui::director { 'localhost': - dir_address => 'localhost', + director_address => 'localhost', } } - create_resources(bareos::webui::director, $directors) + $bareso::webui_directors.each |$key, $values| { + bareos::webui::director { $key: + * => $values, + } + } } diff --git a/manifests/webui/director.pp b/manifests/webui/director.pp index d92a6fa..03b72d8 100644 --- a/manifests/webui/director.pp +++ b/manifests/webui/director.pp @@ -43,35 +43,40 @@ # Bareos default: not set # Required: false define bareos::webui::director ( - Enum['present', 'absent'] $ensure = present, - Optional[Bareos::Resource] $catalog = undef, - Stdlib::Host $dir_address = 'localhost', - Stdlib::Port $dir_port = 9101, - Enum['yes', 'no'] $enabled = 'yes', - Optional[Bareos::Resource] $pam_console_name = undef, - Optional[String] $pam_console_password = undef, + Enum['present', 'absent'] $ensure = present, + Optional[Bareos::Resource] $catalog = undef, + Stdlib::Host $director_address = 'localhost', + Stdlib::Port $director_port = 9101, + Enum['yes', 'no'] $enabled = 'yes', + Optional[Bareos::Resource] $pam_console_name = undef, + Optional[String] $pam_console_password = undef, ) { - include bareos::webui + assert_private() - unless $ensure in ['present', 'absent'] { - fail('Invalid value for ensure') + if ! defined("Concat[${bareos::webui_config_directory}/directors.ini]") { + concat { "${bareos::webui_config_directory}/directors.ini": + ensure => present, + mode => '0644', + owner => 'root', + group => 'root', + tag => [ 'bareos', 'bareos_webui', ], + } } - if $ensure == 'present' { - # just for validation - $_validate = bareos_settings( [$catalog, 'Catalog', 'res', false], - [$dir_address, 'Dir Address', 'address', true], - [$dir_port, 'Dir Port', 'port', true], - [$enabled, 'Enabled', 'bit', true], - [$name, 'Dir Name', 'res', true], - [$pam_console_name, 'Pam Console Name', 'res', false], - [$pam_console_password, 'Pam Console Password', 'autopassword', false] - ) - concat::fragment { "bareos webui director ${title}": - target => "${bareos::webui::config_dir}/directors.ini", - content => template('bareos/webui_directors.erb'), - notify => Service[$bareos::webui::service_name], - tag => ['bareos', 'bareos_webui'], - } + concat::fragment { "bareos webui director ${title}": + ensure => $ensure, + target => "${bareos::webui_config_directory}/directors.ini", + content => epp('bareos/webui/webui_directors.erb', + { + 'catalog' => $catalog, + 'director_address' => $director_address, + 'director_port' => $director_port, + 'enabled' => $enabled, + 'pam_console_name' => $pam_console_name, + 'pam_console_password' => $pam_console_password, + } + ), + notify => Service[$bareos::webui_service], + tag => [ 'bareos', 'bareos_webui', ], } } diff --git a/metadata.json b/metadata.json index 98ba6d0..6391423 100644 --- a/metadata.json +++ b/metadata.json @@ -35,7 +35,8 @@ { "operatingsystem": "Debian", "operatingsystemrelease": [ - "9" + "9", + "10" ] }, { diff --git a/spec/classes/client_client_spec.rb b/spec/classes/client_client_spec.rb deleted file mode 100644 index 11186f6..0000000 --- a/spec/classes/client_client_spec.rb +++ /dev/null @@ -1,96 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::client::client' do - filename = '/etc/bareos/bareos-fd.d/client/bareos-fd.conf' - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - context 'with default values for all parameters' do - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::client') } - it { is_expected.to contain_file(filename).with_content(%r{^Client \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "bareos-fd"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_client]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Client') - res.param('name_client', 'Name', 'name').param_val('name_client', 'bareos-fd', '"bareos-fd"'). - param('description', 'Description', 'string'). - param('absolute_job_timeout', 'Absolute Job Timeout', 'pint32'). - param('allow_bandwidth_bursting', 'Allow Bandwidth Bursting', 'boolean'). - param('allowed_job_command', 'Allowed Job Command', 'string_list'). - param('allowed_script_dir', 'Allowed Script Dir', 'directory_list'). - param('always_use_lmdb', 'Always Use Lmdb', 'boolean'). - param('compatible', 'Compatible', 'boolean'). - param('fd_address', 'Fd Address', 'address'). - param('fd_addresses', 'Fd Addresses', 'addresses'). - param('fd_port', 'Fd Port', 'port'). - param('fd_source_address', 'Fd Source Address', 'address'). - param('heartbeat_interval', 'Heartbeat Interval', 'time'). - param('lmdb_threshold', 'Lmdb Threshold', 'pint32'). - param('log_timestamp_format', 'Log Timestamp Format', 'string'). - param('maximum_bandwidth_per_job', 'Maximum Bandwidth Per Job', 'speed'). - param('maximum_concurrent_jobs', 'Maximum Concurrent Jobs', 'pint32'). - param('maximum_connections', 'Maximum Connections', 'pint32'). - param('maximum_network_buffer_size', 'Maximum Network Buffer Size', 'pint32'). - param('messages', 'Messages', 'res'). - param('pid_directory', 'Pid Directory', 'directory'). - param('pki_cipher', 'Pki Cipher', 'encryption_cipher'). - param('pki_encryption', 'Pki Encryption', 'boolean'). - param('pki_key_pair', 'Pki Key Pair', 'directory'). - param('pki_master_key', 'Pki Master Key', 'directory_list'). - param('pki_signatures', 'Pki Signatures', 'boolean'). - param('pki_signer', 'Pki Signer', 'directory_list'). - param('plugin_directory', 'Plugin Directory', 'directory'). - param('plugin_names', 'Plugin Names', 'plugin_names'). - param('scripts_directory', 'Scripts Directory', 'directory'). - param('sd_connect_timeout', 'Sd Connect Timeout', 'time'). - param('secure_erase_command', 'Secure Erase Command', 'string'). - param('tls_allowed_cn', 'Tls Allowed Cn', 'string_list'). - param('tls_authenticate', 'Tls Authenticate', 'boolean'). - param('tls_ca_certificate_dir', 'Tls Ca Certificate Dir', 'directory'). - param('tls_ca_certificate_file', 'Tls Ca Certificate File', 'directory'). - param('tls_certificate', 'Tls Certificate', 'directory'). - param('tls_certificate_revocation_list', 'Tls Certificate Revocation List', 'directory'). - param('tls_cipher_list', 'Tls Cipher List', 'string'). - param('tls_dh_file', 'Tls Dh File', 'directory'). - param('tls_enable', 'Tls Enable', 'boolean'). - param('tls_key', 'Tls Key', 'directory'). - param('tls_require', 'Tls Require', 'boolean'). - param('tls_verify_peer', 'Tls Verify Peer', 'boolean'). - param('ver_id', 'Ver Id', 'string'). - param('working_directory', 'Working Directory', 'directory') - - let(:params) { res.params } - # required resources - let(:pre_condition) do - ' - bareos::client::messages { "name":} - ' - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-fd]'). - that_requires('Bareos::Client::Messages[name]') - end - end - - context 'ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/classes/client_spec.rb b/spec/classes/client_spec.rb deleted file mode 100644 index 1b3224f..0000000 --- a/spec/classes/client_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' -describe 'bareos::client' do - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - context 'with default values for all parameters' do - it { is_expected.to compile } - it { is_expected.to contain_class('bareos') } - end - end - end -end diff --git a/spec/classes/console_spec.rb b/spec/classes/console_spec.rb deleted file mode 100644 index 9e8b274..0000000 --- a/spec/classes/console_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' -describe 'bareos::console' do - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - context 'with default values for all parameters' do - it { is_expected.to compile } - it { is_expected.to contain_class('bareos') } - end - end - end -end diff --git a/spec/classes/director_director_spec.rb b/spec/classes/director_director_spec.rb deleted file mode 100644 index c0e7f2a..0000000 --- a/spec/classes/director_director_spec.rb +++ /dev/null @@ -1,98 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::director::director' do - filename = '/etc/bareos/bareos-dir.d/director/bareos-dir.conf' - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - context 'with default values for all parameters' do - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::director') } - it { is_expected.to contain_file(filename).with_content(%r{^Director \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "bareos-dir"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_director]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Director') - res.param('name_director', 'Name', 'name').param_val('name_director', 'bareos-dir', '"bareos-dir"'). - param('description', 'Description', 'string'). - param('absolute_job_timeout', 'Absolute Job Timeout', 'pint32'). - param('audit_events', 'Audit Events', 'audit_command_list'). - param('auditing', 'Auditing', 'boolean'). - param('backend_directory', 'Backend Directory', 'directory_list'). - param('dir_address', 'Dir Address', 'address'). - param('dir_addresses', 'Dir Addresses', 'addresses'). - param('dir_port', 'Dir Port', 'port'). - param('dir_source_address', 'Dir Source Address', 'address'). - param('fd_connect_timeout', 'Fd Connect Timeout', 'time'). - param('heartbeat_interval', 'Heartbeat Interval', 'time'). - param('key_encryption_key', 'Key Encryption Key', 'autopassword'). - param('log_timestamp_format', 'Log Timestamp Format', 'string'). - param('maximum_concurrent_jobs', 'Maximum Concurrent Jobs', 'pint32'). - param('maximum_connections', 'Maximum Connections', 'pint32'). - param('maximum_console_connections', 'Maximum Console Connections', 'pint32'). - param('messages', 'Messages', 'res'). - param('ndmp_log_level', 'Ndmp Log Level', 'pint32'). - param('ndmp_snooping', 'Ndmp Snooping', 'boolean'). - param('omit_defaults', 'Omit Defaults', 'boolean'). - param('optimize_for_size', 'Optimize For Size', 'boolean'). - param('optimize_for_speed', 'Optimize For Speed', 'boolean'). - param('password', 'Password', 'autopassword'). - param('pid_directory', 'Pid Directory', 'directory'). - param('plugin_directory', 'Plugin Directory', 'directory'). - param('plugin_names', 'Plugin Names', 'plugin_names'). - param('query_file', 'Query File', 'directory'). - param('scripts_directory', 'Scripts Directory', 'directory'). - param('sd_connect_timeout', 'Sd Connect Timeout', 'time'). - param('secure_erase_command', 'Secure Erase Command', 'string'). - param('statistics_collect_interval', 'Statistics Collect Interval', 'pint32'). - param('statistics_retention', 'Statistics Retention', 'time'). - param('subscriptions', 'Subscriptions', 'pint32'). - param('tls_allowed_cn', 'Tls Allowed Cn', 'string_list'). - param('tls_authenticate', 'Tls Authenticate', 'boolean'). - param('tls_ca_certificate_dir', 'Tls Ca Certificate Dir', 'directory'). - param('tls_ca_certificate_file', 'Tls Ca Certificate File', 'directory'). - param('tls_certificate', 'Tls Certificate', 'directory'). - param('tls_certificate_revocation_list', 'Tls Certificate Revocation List', 'directory'). - param('tls_cipher_list', 'Tls Cipher List', 'string'). - param('tls_dh_file', 'Tls Dh File', 'directory'). - param('tls_enable', 'Tls Enable', 'boolean'). - param('tls_key', 'Tls Key', 'directory'). - param('tls_require', 'Tls Require', 'boolean'). - param('tls_verify_peer', 'Tls Verify Peer', 'boolean'). - param('ver_id', 'Ver Id', 'string'). - param('working_directory', 'Working Directory', 'directory') - - let(:params) { res.params } - # required resources - let(:pre_condition) do - ' - bareos::director::messages { "name":} - ' - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-dir]'). - that_requires('Bareos::Director::Messages[name]') - end - end - - context 'ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/classes/director_spec.rb b/spec/classes/director_spec.rb deleted file mode 100644 index d63a7da..0000000 --- a/spec/classes/director_spec.rb +++ /dev/null @@ -1,53 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::director' do - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - context 'with default values for all parameters' do - it { is_expected.to compile } - it { is_expected.to contain_class('bareos') } - end - - context 'with catalogs => { test: { db_driver: "sqlite", db_name: "test" }}}' do - let(:params) do - { - catalogs: { - test: { - db_driver: 'sqlite', - db_name: 'test' - } - } - } - end - - it { is_expected.to compile } - - it do - expect(subject).to contain_bareos__director__catalog('test'). - with_db_driver('sqlite'). - with_db_name('test') - end - end - end - end - context 'on ubuntu-18.04-x86_64' do - let(:facts) do - { 'service_provider' => 'systemd', }.merge(on_supported_os['ubuntu-18.04-x86_64']) - end - - it { is_expected.to compile.with_all_deps } - - it do - expect(subject).to contain_service('bareos-dir').with( - 'hasrestart' => false, - 'restart' => 'systemctl reload bareos-dir' - ) - end - end -end diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index aa6bcd2..d820ad1 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -1,34 +1,44 @@ -# frozen_string_literal: true - require 'spec_helper' -describe 'bareos' do +require 'shared_examples' + +tests = { + 'with defaults parameters' => {}, + 'with other repository release' => { + 'repository_release' => '21', + }, + 'with not managing client' => { + 'enable_client' => false, + }, +} + + +describe 'bareos', type: :class do on_supported_os.each do |os, facts| context "on #{os}" do - let :facts do + let(:facts) do facts end - context 'with default values for all parameters' do - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos') } - end + defaults = get_defaults(facts) - context 'with repo_subscription: true, repo_username: "test", repo_password: "test"' do - let(:params) do - { - repo_subscription: true, - repo_username: 'test', - repo_password: 'test' - } - end + tests.each do |test, values| + context test do + params = defaults.merge(values) - it { is_expected.to compile } + let(:params) do + params + end + + it { + is_expected.to compile.with_all_deps + is_expected.to contain_class('bareos::params') + } - it do - expect(subject).to contain_class('bareos::repository'). - with_subscription(true). - with_username('test'). - with_password('test') + include_examples 'repository', params, facts + include_examples 'config', params, facts + include_examples 'client', params, facts + include_examples 'console', params, facts + include_examples 'monitor', params, facts end end end diff --git a/spec/classes/monitor_spec.rb b/spec/classes/monitor_spec.rb deleted file mode 100644 index 945740b..0000000 --- a/spec/classes/monitor_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' -describe 'bareos::monitor' do - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - context 'with default values for all parameters' do - it { is_expected.to compile } - it { is_expected.to contain_class('bareos') } - end - end - end -end diff --git a/spec/classes/repository_spec.rb b/spec/classes/repository_spec.rb deleted file mode 100644 index 9bac150..0000000 --- a/spec/classes/repository_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' -describe 'bareos::repository' do - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - context 'with default values for all parameters' do - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::repository') } - end - - case facts[:osfamily] - when 'RedHat' - context 'with subscription: true, username: "test", password: "test"' do - let(:params) do - { - subscription: true, - username: 'test', - password: 'test' - } - end - - it { is_expected.to compile } - - it do - expect(subject).to contain_yumrepo('bareos'). - with_username('test'). - with_password('test') - end - end - when 'Debian' - case facts[:operatingsystemmajrelease] - when '20' - context 'with subscription: true, username: "test", password: "test"' do - let(:params) do - { - subscription: true, - username: 'test', - password: 'test' - } - end - - it { is_expected.to compile } - - it do - expect(subject).to contain_apt__source('bareos'). - with_location('http://test:test@download.bareos.com/bareos/release/latest/xUbuntu_20.04') - end - end - end - end - end - end -end diff --git a/spec/classes/storage_spec.rb b/spec/classes/storage_spec.rb deleted file mode 100644 index eecd6d7..0000000 --- a/spec/classes/storage_spec.rb +++ /dev/null @@ -1,108 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' -describe 'bareos::storage' do - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - context 'with default values for all parameters' do - it { is_expected.to compile } - it { is_expected.to contain_class('bareos') } - end - - context 'with autochangers => { test: { changer_command => "foo", changer_device => "/dev/foo", device => "dev01" }}, devices => { dev01: { archive_device => "/mnt/test", media_type => "file" }}}' do - let(:params) do - { - autochangers: { - test: { - changer_command: 'foo', - changer_device: '/dev/foo', - device: 'dev01' - } - }, - devices: { - dev01: { - archive_device: '/mnt/test', - media_type: 'file' - } - } - } - end - - it { is_expected.to compile } - - it do - expect(subject).to contain_bareos__storage__autochanger('test'). - with_changer_command('foo'). - with_changer_device('/dev/foo'). - with_device('dev01') - expect(subject).to contain_bareos__storage__device('dev01'). - with_archive_device('/mnt/test'). - with_media_type('file') - end - end - - context 'with directors => { test: { password => "foobar" }}}' do - let(:params) do - { - directors: { - test: { - password: 'foobar' - } - } - } - end - - it { is_expected.to compile } - - it do - expect(subject).to contain_bareos__storage__director('test'). - with_password('foobar') - end - end - - context 'with messages => { test: { description => "test" }}}' do - let(:params) do - { - messages: { - test: { - description: 'test' - } - } - } - end - - it { is_expected.to compile } - - it do - expect(subject).to contain_bareos__storage__messages('test'). - with_description('test') - end - end - - context 'with ndmps => { test: { username => "test", password => "foobar" }}}' do - let(:params) do - { - ndmps: { - test: { - username: 'test', - password: 'foobar' - } - } - } - end - - it { is_expected.to compile } - - it do - expect(subject).to contain_bareos__storage__ndmp('test'). - with_username('test'). - with_password('foobar') - end - end - end - end -end diff --git a/spec/classes/storage_storage_spec.rb b/spec/classes/storage_storage_spec.rb deleted file mode 100644 index 4e5bc9f..0000000 --- a/spec/classes/storage_storage_spec.rb +++ /dev/null @@ -1,101 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::storage::storage' do - filename = '/etc/bareos/bareos-sd.d/storage/bareos-sd.conf' - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - context 'with default values for all parameters' do - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::storage') } - it { is_expected.to contain_file(filename).with_content(%r{^Storage \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "bareos-sd"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_storage]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Storage') - res.param('name_storage', 'Name', 'name').param_val('name_storage', 'bareos-sd', '"bareos-sd"'). - param('absolute_job_timeout', 'Absolute Job Timeout', 'pint32'). - param('allow_bandwidth_bursting', 'Allow Bandwidth Bursting', 'boolean'). - param('auto_x_flate_on_replication', 'Auto X Flate On Replication', 'boolean'). - param('backend_directory', 'Backend Directory', 'directory_list'). - param('client_connect_wait', 'Client Connect Wait', 'time'). - param('collect_device_statistics', 'Collect Device Statistics', 'boolean'). - param('collect_job_statistics', 'Collect Job Statistics', 'boolean'). - param('compatible', 'Compatible', 'boolean'). - param('device_reserve_by_media_type', 'Device Reserve By Media Type', 'boolean'). - param('fd_connect_timeout', 'Fd Connect Timeout', 'time'). - param('file_device_concurrent_read', 'File Device Concurrent Read', 'boolean'). - param('heartbeat_interval', 'Heartbeat Interval', 'time'). - param('log_timestamp_format', 'Log Timestamp Format', 'string'). - param('maximum_bandwidth_per_job', 'Maximum Bandwidth Per Job', 'speed'). - param('maximum_concurrent_jobs', 'Maximum Concurrent Jobs', 'pint32'). - param('maximum_connections', 'Maximum Connections', 'pint32'). - param('maximum_network_buffer_size', 'Maximum Network Buffer Size', 'pint32'). - param('messages', 'Messages', 'res'). - param('ndmp_address', 'Ndmp Address', 'address'). - param('ndmp_addresses', 'Ndmp Addresses', 'addresses'). - param('ndmp_enable', 'Ndmp Enable', 'boolean'). - param('ndmp_log_level', 'Ndmp Log Level', 'pint32'). - param('ndmp_port', 'Ndmp Port', 'port'). - param('ndmp_snooping', 'Ndmp Snooping', 'boolean'). - param('pid_directory', 'Pid Directory', 'directory'). - param('plugin_directory', 'Plugin Directory', 'directory'). - param('plugin_names', 'Plugin Names', 'plugin_names'). - param('scripts_directory', 'Scripts Directory', 'directory'). - param('sd_address', 'Sd Address', 'address'). - param('sd_addresses', 'Sd Addresses', 'addresses'). - param('sd_connect_timeout', 'Sd Connect Timeout', 'time'). - param('sd_port', 'Sd Port', 'port'). - param('sd_source_address', 'Sd Source Address', 'address'). - param('secure_erase_command', 'Secure Erase Command', 'string'). - param('statistics_collect_interval', 'Statistics Collect Interval', 'pint32'). - param('sub_sys_directory', 'Sub Sys Directory', 'directory'). - param('tls_allowed_cn', 'Tls Allowed Cn', 'string_list'). - param('tls_authenticate', 'Tls Authenticate', 'boolean'). - param('tls_ca_certificate_dir', 'Tls Ca Certificate Dir', 'directory'). - param('tls_ca_certificate_file', 'Tls Ca Certificate File', 'directory'). - param('tls_certificate', 'Tls Certificate', 'directory'). - param('tls_certificate_revocation_list', 'Tls Certificate Revocation List', 'directory'). - param('tls_cipher_list', 'Tls Cipher List', 'string'). - param('tls_dh_file', 'Tls Dh File', 'directory'). - param('tls_enable', 'Tls Enable', 'boolean'). - param('tls_key', 'Tls Key', 'directory'). - param('tls_require', 'Tls Require', 'boolean'). - param('tls_verify_peer', 'Tls Verify Peer', 'boolean'). - param('ver_id', 'Ver Id', 'string'). - param('working_directory', 'Working Directory', 'directory') - - let(:params) { res.params } - # required resources - let(:pre_condition) do - ' - bareos::storage::messages { "name":} - ' - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-sd]'). - that_requires('Bareos::Storage::Messages[name]') - end - end - - context 'ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/classes/webui_spec.rb b/spec/classes/webui_spec.rb deleted file mode 100644 index 2df6ad5..0000000 --- a/spec/classes/webui_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' -describe 'bareos::webui' do - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - context 'with default values for all parameters' do - it { is_expected.to compile } - it { is_expected.to contain_class('bareos') } - end - - context 'with directors => { test: { dir_address: "example.org", catalog: "MyCatalog" }}}' do - let(:params) do - { - directors: { - test: { - dir_address: 'example.org', - catalog: 'MyCatalog' - } - } - } - end - - it { is_expected.to compile } - - it do - expect(subject).to contain_bareos__webui__director('test'). - with_dir_address('example.org'). - with_catalog('MyCatalog') - end - end - end - end -end diff --git a/spec/defines/client/client_director_spec.rb b/spec/defines/client/client_director_spec.rb deleted file mode 100644 index a176648..0000000 --- a/spec/defines/client/client_director_spec.rb +++ /dev/null @@ -1,77 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::client::director' do - let :node do - 'rspec.puppet.com' - end - let(:title) { 'name' } - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - filename = '/etc/bareos/bareos-fd.d/director/name.conf' - - context 'with default values for all parameters will fail' do - it { is_expected.to compile.and_raise_error(%r{.*}) } - end - - context 'with required values' do - let(:params) { { 'password' => 'password' } } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::client') } - it { is_expected.to contain_file(filename).with_content(%r{^Director \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_client]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Director') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('address', 'Address', 'string'). - param('allowed_job_command', 'Allowed Job Command', 'string_list'). - param('allowed_script_dir', 'Allowed Script Dir', 'directory_list'). - param('connection_from_client_to_director', 'Connection From Client To Director', 'boolean'). - param('connection_from_director_to_client', 'Connection From Director To Client', 'boolean'). - param('maximum_bandwidth_per_job', 'Maximum Bandwidth Per Job', 'speed'). - param('monitor', 'Monitor', 'boolean'). - param('password', 'Password', 'md5password'). - param('port', 'Port', 'pint32'). - param('tls_allowed_cn', 'Tls Allowed Cn', 'string_list'). - param('tls_authenticate', 'Tls Authenticate', 'boolean'). - param('tls_ca_certificate_dir', 'Tls Ca Certificate Dir', 'directory'). - param('tls_ca_certificate_file', 'Tls Ca Certificate File', 'directory'). - param('tls_certificate', 'Tls Certificate', 'directory'). - param('tls_certificate_revocation_list', 'Tls Certificate Revocation List', 'directory'). - param('tls_cipher_list', 'Tls Cipher List', 'string'). - param('tls_dh_file', 'Tls Dh File', 'directory'). - param('tls_enable', 'Tls Enable', 'boolean'). - param('tls_key', 'Tls Key', 'directory'). - param('tls_require', 'Tls Require', 'boolean'). - param('tls_verify_peer', 'Tls Verify Peer', 'boolean') - - let(:params) { res.params } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-fd]') - end - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/client/client_messages_spec.rb b/spec/defines/client/client_messages_spec.rb deleted file mode 100644 index 85556ba..0000000 --- a/spec/defines/client/client_messages_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::client::messages' do - let :node do - 'rspec.puppet.com' - end - let(:title) { 'name' } - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - filename = '/etc/bareos/bareos-fd.d/messages/name.conf' - - context 'with default values for all parameters' do - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::client') } - it { is_expected.to contain_file(filename).with_content(%r{^Messages \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_client]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Messages') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('append', 'Append', 'messages_list'). - param('catalog', 'Catalog', 'messages_list'). - param('console', 'Console', 'messages_list'). - param('director', 'Director', 'messages_list'). - param('file', 'File', 'messages_list'). - param('mail_command', 'Mail Command', 'string'). - param('mail', 'Mail', 'messages_list'). - param('mail_on_error', 'Mail On Error', 'messages_list'). - param('mail_on_success', 'Mail On Success', 'messages_list'). - param('operator_command', 'Operator Command', 'string'). - param('operator', 'Operator', 'messages_list'). - param('stderr', 'Stderr', 'messages_list'). - param('stdout', 'Stdout', 'messages_list'). - param('syslog', 'Syslog', 'messages_list'). - param('timestamp_format', 'Timestamp Format', 'string') - - let(:params) { res.params } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-fd]') - end - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/console/console_console_spec.rb b/spec/defines/console/console_console_spec.rb deleted file mode 100644 index 41356da..0000000 --- a/spec/defines/console/console_console_spec.rb +++ /dev/null @@ -1,69 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::console::console' do - let :node do - 'rspec.puppet.com' - end - let(:title) { 'name' } - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - filename = '/etc/bareos/bconsole.d/console/name.conf' - - context 'with default values for all parameters will fail' do - it { is_expected.to compile.and_raise_error(%r{.*}) } - end - - context 'with required values' do - let(:params) { { 'password' => 'password' } } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::console') } - it { is_expected.to contain_file(filename).with_content(%r{^Console \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_console]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Console') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('director', 'Director', 'string'). - param('heartbeat_interval', 'Heartbeat Interval', 'time'). - param('history_file', 'History File', 'directory'). - param('history_length', 'History Length', 'pint32'). - param('password', 'Password', 'md5password'). - param('rc_file', 'Rc File', 'directory'). - param('tls_allowed_cn', 'Tls Allowed Cn', 'string_list'). - param('tls_authenticate', 'Tls Authenticate', 'boolean'). - param('tls_ca_certificate_dir', 'Tls Ca Certificate Dir', 'directory'). - param('tls_ca_certificate_file', 'Tls Ca Certificate File', 'directory'). - param('tls_certificate', 'Tls Certificate', 'directory'). - param('tls_certificate_revocation_list', 'Tls Certificate Revocation List', 'directory'). - param('tls_cipher_list', 'Tls Cipher List', 'string'). - param('tls_dh_file', 'Tls Dh File', 'directory'). - param('tls_enable', 'Tls Enable', 'boolean'). - param('tls_key', 'Tls Key', 'directory'). - param('tls_require', 'Tls Require', 'boolean'). - param('tls_verify_peer', 'Tls Verify Peer', 'boolean') - - let(:params) { res.params } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/console/console_director_spec.rb b/spec/defines/console/console_director_spec.rb deleted file mode 100644 index f16c3ef..0000000 --- a/spec/defines/console/console_director_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::console::director' do - let :node do - 'rspec.puppet.com' - end - let(:title) { 'name' } - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - filename = '/etc/bareos/bconsole.d/director/name.conf' - - context 'with default values for all parameters will fail' do - it { is_expected.to compile.and_raise_error(%r{.*}) } - end - - context 'with required values' do - let(:params) { { 'password' => 'password' } } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::console') } - it { is_expected.to contain_file(filename).with_content(%r{^Director \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_console]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Director') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('address', 'Address', 'string'). - param('dir_port', 'Dir Port', 'pint32'). - param('heartbeat_interval', 'Heartbeat Interval', 'time'). - param('password', 'Password', 'md5password'). - param('tls_allowed_cn', 'Tls Allowed Cn', 'string_list'). - param('tls_authenticate', 'Tls Authenticate', 'boolean'). - param('tls_ca_certificate_dir', 'Tls Ca Certificate Dir', 'directory'). - param('tls_ca_certificate_file', 'Tls Ca Certificate File', 'directory'). - param('tls_certificate', 'Tls Certificate', 'directory'). - param('tls_certificate_revocation_list', 'Tls Certificate Revocation List', 'directory'). - param('tls_cipher_list', 'Tls Cipher List', 'string'). - param('tls_dh_file', 'Tls Dh File', 'directory'). - param('tls_enable', 'Tls Enable', 'boolean'). - param('tls_key', 'Tls Key', 'directory'). - param('tls_require', 'Tls Require', 'boolean'). - param('tls_verify_peer', 'Tls Verify Peer', 'boolean') - - let(:params) { res.params } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/director/director_catalog.rb b/spec/defines/director/director_catalog.rb deleted file mode 100644 index a96637e..0000000 --- a/spec/defines/director/director_catalog.rb +++ /dev/null @@ -1,78 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::director::catalog' do - let :node do - 'rspec.puppet.com' - end - let(:title) { 'name' } - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - filename = '/etc/bareos/bareos-dir.d/catalog/name.conf' - - context 'with default values for all parameters will fail' do - it { is_expected.to compile.and_raise_error(%r{.*}) } - end - - context 'with required values' do - let(:params) do - { - 'db_driver' => 'mysql', - 'db_name' => 'catalogdb' - } - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::director') } - it { is_expected.to contain_file(filename).with_content(%r{^Catalog \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_director]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Catalog') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('db_address', 'Db Address', 'string'). - param('db_driver', 'Db Driver', 'string'). - param('db_name', 'Db Name', 'string'). - param('db_password', 'Db Password', 'autopassword'). - param('db_port', 'Db Port', 'pint32'). - param('db_socket', 'Db Socket', 'string'). - param('db_user', 'Db User', 'string'). - param('disable_batch_insert', 'Disable Batch Insert', 'boolean'). - param('exit_on_fatal', 'Exit On Fatal', 'boolean'). - param('idle_timeout', 'Idle Timeout', 'pint32'). - param('inc_connections', 'Inc Connections', 'pint32'). - param('max_connections', 'Max Connections', 'pint32'). - param('min_connections', 'Min Connections', 'pint32'). - param('multiple_connections', 'Multiple Connections', 'bit'). - param('reconnect', 'Reconnect', 'boolean'). - param('validate_timeout', 'Validate Timeout', 'pint32') - - let(:params) { res.params } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-dir]'). - that_notifies('Exec[bareos director init catalog]') - end - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/director/director_client_spec.rb b/spec/defines/director/director_client_spec.rb deleted file mode 100644 index 34f20ad..0000000 --- a/spec/defines/director/director_client_spec.rb +++ /dev/null @@ -1,103 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::director::client' do - let :node do - 'rspec.puppet.com' - end - let(:title) { 'name' } - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - filename = '/etc/bareos/bareos-dir.d/client/name.conf' - - context 'with default values for all parameters will fail' do - it { is_expected.to compile.and_raise_error(%r{.*}) } - end - - context 'with required values' do - let(:params) { { 'password' => 'password', 'address' => '127.0.0.1' } } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::director') } - it { is_expected.to contain_file(filename).with_content(%r{^Client \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_director]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Client') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('address', 'Address', 'string'). - param('auth_type', 'Auth Type', 'auth_type'). - param('auto_prune', 'Auto Prune', 'boolean'). - param('catalog', 'Catalog', 'res'). - param('connection_from_client_to_director', 'Connection From Client To Director', 'boolean'). - param('connection_from_director_to_client', 'Connection From Director To Client', 'boolean'). - param('enabled', 'Enabled', 'boolean'). - param('file_retention', 'File Retention', 'time'). - param('hard_quota', 'Hard Quota', 'size64'). - param('heartbeat_interval', 'Heartbeat Interval', 'time'). - param('job_retention', 'Job Retention', 'time'). - param('maximum_bandwidth_per_job', 'Maximum Bandwidth Per Job', 'speed'). - param('maximum_concurrent_jobs', 'Maximum Concurrent Jobs', 'pint32'). - param('ndmp_block_size', 'Ndmp Block Size', 'pint32'). - param('ndmp_log_level', 'Ndmp Log Level', 'pint32'). - param('ndmp_use_lmdb', 'Ndmp Use Lmdb', 'boolean'). - param('passive', 'Passive', 'boolean'). - param('password', 'Password', 'autopassword'). - param('port', 'Port', 'pint32'). - param('protocol', 'Protocol', 'auth_protocol_type'). - param('quota_include_failed_jobs', 'Quota Include Failed Jobs', 'boolean'). - param('soft_quota', 'Soft Quota', 'size64'). - param('soft_quota_grace_period', 'Soft Quota Grace Period', 'time'). - param('strict_quotas', 'Strict Quotas', 'boolean'). - param('tls_allowed_cn', 'Tls Allowed Cn', 'string_list'). - param('tls_authenticate', 'Tls Authenticate', 'boolean'). - param('tls_ca_certificate_dir', 'Tls Ca Certificate Dir', 'directory'). - param('tls_ca_certificate_file', 'Tls Ca Certificate File', 'directory'). - param('tls_certificate', 'Tls Certificate', 'directory'). - param('tls_certificate_revocation_list', 'Tls Certificate Revocation List', 'directory'). - param('tls_cipher_list', 'Tls Cipher List', 'string'). - param('tls_dh_file', 'Tls Dh File', 'directory'). - param('tls_enable', 'Tls Enable', 'boolean'). - param('tls_key', 'Tls Key', 'directory'). - param('tls_require', 'Tls Require', 'boolean'). - param('tls_verify_peer', 'Tls Verify Peer', 'boolean'). - param('username', 'Username', 'string') - - let(:params) { res.params } - # required resources - let(:pre_condition) do - ' - bareos::director::catalog { "name": - db_driver => "sqlite3", - db_name => "test", - } - ' - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-dir]'). - that_requires('Bareos::Director::Catalog[name]') - end - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/director/director_console_spec.rb b/spec/defines/director/director_console_spec.rb deleted file mode 100644 index d2cf2dc..0000000 --- a/spec/defines/director/director_console_spec.rb +++ /dev/null @@ -1,92 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::director::console' do - let :node do - 'rspec.puppet.com' - end - let(:title) { 'name' } - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - filename = '/etc/bareos/bareos-dir.d/console/name.conf' - - context 'with default values for all parameters will fail' do - it { is_expected.to compile.and_raise_error(%r{.*}) } - end - - context 'with required values' do - let(:params) do - { - 'password' => 'pw' - } - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::director') } - it { is_expected.to contain_file(filename).with_content(%r{^Console \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_director]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Console') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('catalog_acl', 'Catalog ACL', 'acl'). - param('client_acl', 'Client ACL', 'acl'). - param('command_acl', 'Command ACL', 'acl'). - param('file_set_acl', 'File Set ACL', 'acl'). - param('job_acl', 'Job ACL', 'acl'). - param('password', 'Password', 'autopassword'). - param('plugin_options_acl', 'Plugin Options ACL', 'acl'). - param('pool_acl', 'Pool ACL', 'acl'). - param('profile', 'Profile', 'resource_list'). - param('run_acl', 'Run ACL', 'acl'). - param('schedule_acl', 'Schedule ACL', 'acl'). - param('storage_acl', 'Storage ACL', 'acl'). - param('tls_allowed_cn', 'Tls Allowed Cn', 'string_list'). - param('tls_authenticate', 'Tls Authenticate', 'boolean'). - param('tls_ca_certificate_dir', 'Tls Ca Certificate Dir', 'directory'). - param('tls_ca_certificate_file', 'Tls Ca Certificate File', 'directory'). - param('tls_certificate', 'Tls Certificate', 'directory'). - param('tls_certificate_revocation_list', 'Tls Certificate Revocation List', 'directory'). - param('tls_cipher_list', 'Tls Cipher List', 'string'). - param('tls_dh_file', 'Tls Dh File', 'directory'). - param('tls_enable', 'Tls Enable', 'boolean'). - param('tls_key', 'Tls Key', 'directory'). - param('tls_require', 'Tls Require', 'boolean'). - param('tls_verify_peer', 'Tls Verify Peer', 'boolean'). - param('where_acl', 'Where ACL', 'acl') - - let(:params) { res.params } - # required resources - let(:pre_condition) do - ' - bareos::director::profile { "name": } - ' - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-dir]'). - that_requires('Bareos::Director::Profile[name]') - end - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/director/director_counter_spec.rb b/spec/defines/director/director_counter_spec.rb deleted file mode 100644 index 20715d5..0000000 --- a/spec/defines/director/director_counter_spec.rb +++ /dev/null @@ -1,64 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::director::counter' do - let :node do - 'rspec.puppet.com' - end - let(:title) { 'name' } - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - filename = '/etc/bareos/bareos-dir.d/counter/name.conf' - - context 'with default values for all parameters' do - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::director') } - it { is_expected.to contain_file(filename).with_content(%r{^Counter \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_director]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Counter') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('catalog', 'Catalog', 'res'). - param('maximum', 'Maximum', 'pint32'). - param('minimum', 'Minimum', 'int32'). - param('wrap_counter', 'Wrap Counter', 'res') - - let(:params) { res.params } - # required resources - let(:pre_condition) do - ' - bareos::director::catalog { "name": - db_driver => "sqlite3", - db_name => "test", - } - ' - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-dir]'). - that_requires('Bareos::Director::Catalog[name]') - end - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/director/director_fileset_spec.rb b/spec/defines/director/director_fileset_spec.rb deleted file mode 100644 index 5e2834b..0000000 --- a/spec/defines/director/director_fileset_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::director::fileset' do - let(:title) { 'name' } - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - filename = '/etc/bareos/bareos-dir.d/fileset/name.conf' - - context 'with default values for all parameters' do - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::director') } - it { is_expected.to contain_file(filename).with_content(%r{^FileSet \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_director]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('FileSet') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('enable_vss', 'Enable VSS', 'boolean'). - param('exclude', 'Exclude', 'include_exclude_item'). - param('ignore_file_set_changes', 'Ignore File Set Changes', 'boolean'). - param('include', 'Include', 'include_exclude_item') - - let(:params) { res.params } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-dir]') - end - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/director/director_job_spec.rb b/spec/defines/director/director_job_spec.rb deleted file mode 100644 index 49a2db4..0000000 --- a/spec/defines/director/director_job_spec.rb +++ /dev/null @@ -1,188 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::director::job' do - let :node do - 'rspec.puppet.com' - end - let(:title) { 'name' } - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - filename = '/etc/bareos/bareos-dir.d/job/name.conf' - - context 'with default values for all parameters will fail' do - it { is_expected.to compile.and_raise_error(%r{.*}) } - end - - context 'with required values' do - let(:params) do - { - 'messages' => 'name', - 'pool' => 'name', - 'type' => 'backup' - } - end - let(:pre_condition) do - ' - bareos::director::pool { "name": } - bareos::director::messages { "name": } - ' - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::director') } - it { is_expected.to contain_file(filename).with_content(%r{^Job \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_director]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Job') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('accurate', 'Accurate', 'boolean'). - param('add_prefix', 'Add Prefix', 'string'). - param('add_suffix', 'Add Suffix', 'string'). - param('allow_duplicate_jobs', 'Allow Duplicate Jobs', 'boolean'). - param('allow_higher_duplicates', 'Allow Higher Duplicates', 'boolean'). - param('allow_mixed_priority', 'Allow Mixed Priority', 'boolean'). - param('always_incremental', 'Always Incremental', 'boolean'). - param('always_incremental_job_retention', 'Always Incremental Job Retention', 'time'). - param('always_incremental_keep_number', 'Always Incremental Keep Number', 'pint32'). - param('always_incremental_max_full_age', 'Always Incremental Max Full Age', 'time'). - param('backup_format', 'Backup Format', 'string'). - param('base', 'Base', 'resource_list').param_val('base', 'name2', '"name2"'). - param('bootstrap', 'Bootstrap', 'directory'). - param('cancel_lower_level_duplicates', 'Cancel Lower Level Duplicates', 'boolean'). - param('cancel_queued_duplicates', 'Cancel Queued Duplicates', 'boolean'). - param('cancel_running_duplicates', 'Cancel Running Duplicates', 'boolean'). - param('catalog', 'Catalog', 'res'). - param('client', 'Client', 'res'). - param('client_run_after_job', 'Client Run After Job', 'runscript_short'). - param('client_run_before_job', 'Client Run Before Job', 'runscript_short'). - param('differential_backup_pool', 'Differential Backup Pool', 'res'). - param('differential_max_runtime', 'Differential Max Runtime', 'time'). - param('dir_plugin_options', 'Dir Plugin Options', 'string_list'). - param('enabled', 'Enabled', 'boolean'). - param('fd_plugin_options', 'Fd Plugin Options', 'string_list'). - param('file_history_size', 'File History Size', 'size64'). - param('file_set', 'File Set', 'res'). - param('full_backup_pool', 'Full Backup Pool', 'res'). - param('full_max_runtime', 'Full Max Runtime', 'time'). - param('incremental_backup_pool', 'Incremental Backup Pool', 'res'). - param('incremental_max_runtime', 'Incremental Max Runtime', 'time'). - param('job_defs', 'Job Defs', 'res'). - param('job_to_verify', 'Job To Verify', 'res').param_val('job_to_verify', 'name2', '"name2"'). - param('level', 'Level', 'backup_level'). - param('max_concurrent_copies', 'Max Concurrent Copies', 'pint32'). - param('max_diff_interval', 'Max Diff Interval', 'time'). - param('max_full_consolidations', 'Max Full Consolidations', 'pint32'). - param('max_full_interval', 'Max Full Interval', 'time'). - param('max_run_sched_time', 'Max Run Sched Time', 'time'). - param('max_run_time', 'Max Run Time', 'time'). - param('max_start_delay', 'Max Start Delay', 'time'). - param('max_virtual_full_interval', 'Max Virtual Full Interval', 'time'). - param('max_wait_time', 'Max Wait Time', 'time'). - param('maximum_bandwidth', 'Maximum Bandwidth', 'speed'). - param('maximum_concurrent_jobs', 'Maximum Concurrent Jobs', 'pint32'). - param('messages', 'Messages', 'res'). - param('next_pool', 'Next Pool', 'res'). - param('pool', 'Pool', 'res'). - param('prefer_mounted_volumes', 'Prefer Mounted Volumes', 'boolean'). - param('prefix_links', 'Prefix Links', 'boolean'). - param('priority', 'Priority', 'pint32'). - param('protocol', 'Protocol', 'protocol_type'). - param('prune_files', 'Prune Files', 'boolean'). - param('prune_jobs', 'Prune Jobs', 'boolean'). - param('prune_volumes', 'Prune Volumes', 'boolean'). - param('purge_migration_job', 'Purge Migration Job', 'boolean'). - param('regex_where', 'Regex Where', 'string'). - param('replace', 'Replace', 'replace_option'). - param('rerun_failed_levels', 'Rerun Failed Levels', 'boolean'). - param('reschedule_interval', 'Reschedule Interval', 'time'). - param('reschedule_on_error', 'Reschedule On Error', 'boolean'). - param('reschedule_times', 'Reschedule Times', 'pint32'). - param('run', 'Run', 'string_list'). - param('run_after_failed_job', 'Run After Failed Job', 'runscript_short'). - param('run_after_job', 'Run After Job', 'runscript_short'). - param('run_before_job', 'Run Before Job', 'runscript_short'). - param('run_script', 'Run Script', 'runscript'). - param('save_file_history', 'Save File History', 'boolean'). - param('schedule_res', 'Schedule', 'res'). - param('sd_plugin_options', 'Sd Plugin Options', 'string_list'). - param('selection_pattern', 'Selection Pattern', 'string'). - param('selection_type', 'Selection Type', 'migration_type'). - param('spool_attributes', 'Spool Attributes', 'boolean'). - param('spool_data', 'Spool Data', 'boolean'). - param('spool_size', 'Spool Size', 'size64'). - param('storage', 'Storage', 'resource_list'). - param('strip_prefix', 'Strip Prefix', 'string'). - param('type', 'Type', 'job_type'). - param('virtual_full_backup_pool', 'Virtual Full Backup Pool', 'res'). - param('where', 'Where', 'directory'). - param('write_bootstrap', 'Write Bootstrap', 'directory'). - param('write_verify_list', 'Write Verify List', 'directory') - - let(:params) { res.params } - # required resources - let(:pre_condition) do - ' - bareos::director::pool { "name": } - bareos::director::catalog { "name": - db_driver => "sqlite3", - db_name => "test", - } - bareos::director::storage { "name": - address => "127.0.0.1", - device => "Device", - media_type => "File", - password => "pw", - } - bareos::director::client { "name": - address => "127.0.0.1", - password => "pw", - } - bareos::director::fileset { "name": } - bareos::director::schedule { "name": } - bareos::director::messages { "name": } - bareos::director::job { "name2": - messages => "name", - pool => "name", - type => "backup", - } - bareos::director::jobdefs { "name": } - ' - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-dir]'). - that_requires('Bareos::Director::Catalog[name]'). - that_requires('Bareos::Director::Storage[name]'). - that_requires('Bareos::Director::Schedule[name]'). - that_requires('Bareos::Director::Messages[name]'). - that_requires('Bareos::Director::Client[name]'). - that_requires('Bareos::Director::Fileset[name]'). - that_requires('Bareos::Director::Job[name2]'). - that_requires('Bareos::Director::Jobdefs[name]'). - that_requires('Bareos::Director::Pool[name]') - end - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/director/director_jobdefs_spec.rb b/spec/defines/director/director_jobdefs_spec.rb deleted file mode 100644 index 0f5b6aa..0000000 --- a/spec/defines/director/director_jobdefs_spec.rb +++ /dev/null @@ -1,167 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::director::jobdefs' do - let(:title) { 'name' } - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - filename = '/etc/bareos/bareos-dir.d/jobdefs/name.conf' - - context 'with default values for all parameters will fail' do - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::director') } - it { is_expected.to contain_file(filename).with_content(%r{^JobDefs \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_director]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('JobDefs') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('accurate', 'Accurate', 'boolean'). - param('add_prefix', 'Add Prefix', 'string'). - param('add_suffix', 'Add Suffix', 'string'). - param('allow_duplicate_jobs', 'Allow Duplicate Jobs', 'boolean'). - param('allow_higher_duplicates', 'Allow Higher Duplicates', 'boolean'). - param('allow_mixed_priority', 'Allow Mixed Priority', 'boolean'). - param('always_incremental', 'Always Incremental', 'boolean'). - param('always_incremental_job_retention', 'Always Incremental Job Retention', 'time'). - param('always_incremental_keep_number', 'Always Incremental Keep Number', 'pint32'). - param('always_incremental_max_full_age', 'Always Incremental Max Full Age', 'time'). - param('backup_format', 'Backup Format', 'string'). - param('base', 'Base', 'resource_list').param_val('base', 'name2', '"name2"'). - param('bootstrap', 'Bootstrap', 'directory'). - param('cancel_lower_level_duplicates', 'Cancel Lower Level Duplicates', 'boolean'). - param('cancel_queued_duplicates', 'Cancel Queued Duplicates', 'boolean'). - param('cancel_running_duplicates', 'Cancel Running Duplicates', 'boolean'). - param('catalog', 'Catalog', 'res'). - param('client', 'Client', 'res'). - param('client_run_after_job', 'Client Run After Job', 'runscript_short'). - param('client_run_before_job', 'Client Run Before Job', 'runscript_short'). - param('differential_backup_pool', 'Differential Backup Pool', 'res'). - param('differential_max_runtime', 'Differential Max Runtime', 'time'). - param('dir_plugin_options', 'Dir Plugin Options', 'string_list'). - param('enabled', 'Enabled', 'boolean'). - param('fd_plugin_options', 'Fd Plugin Options', 'string_list'). - param('file_history_size', 'File History Size', 'size64'). - param('file_set', 'File Set', 'res'). - param('full_backup_pool', 'Full Backup Pool', 'res'). - param('full_max_runtime', 'Full Max Runtime', 'time'). - param('incremental_backup_pool', 'Incremental Backup Pool', 'res'). - param('incremental_max_runtime', 'Incremental Max Runtime', 'time'). - param('job_defs', 'Job Defs', 'res').param_val('job_defs', 'name2', '"name2"'). - param('job_to_verify', 'Job To Verify', 'res').param_val('job_to_verify', 'name2', '"name2"'). - param('level', 'Level', 'backup_level'). - param('max_concurrent_copies', 'Max Concurrent Copies', 'pint32'). - param('max_diff_interval', 'Max Diff Interval', 'time'). - param('max_full_consolidations', 'Max Full Consolidations', 'pint32'). - param('max_full_interval', 'Max Full Interval', 'time'). - param('max_run_sched_time', 'Max Run Sched Time', 'time'). - param('max_run_time', 'Max Run Time', 'time'). - param('max_start_delay', 'Max Start Delay', 'time'). - param('max_virtual_full_interval', 'Max Virtual Full Interval', 'time'). - param('max_wait_time', 'Max Wait Time', 'time'). - param('maximum_bandwidth', 'Maximum Bandwidth', 'speed'). - param('maximum_concurrent_jobs', 'Maximum Concurrent Jobs', 'pint32'). - param('messages', 'Messages', 'res'). - param('next_pool', 'Next Pool', 'res'). - param('pool', 'Pool', 'res'). - param('prefer_mounted_volumes', 'Prefer Mounted Volumes', 'boolean'). - param('prefix_links', 'Prefix Links', 'boolean'). - param('priority', 'Priority', 'pint32'). - param('protocol', 'Protocol', 'protocol_type'). - param('prune_files', 'Prune Files', 'boolean'). - param('prune_jobs', 'Prune Jobs', 'boolean'). - param('prune_volumes', 'Prune Volumes', 'boolean'). - param('purge_migration_job', 'Purge Migration Job', 'boolean'). - param('regex_where', 'Regex Where', 'string'). - param('replace', 'Replace', 'replace_option'). - param('rerun_failed_levels', 'Rerun Failed Levels', 'boolean'). - param('reschedule_interval', 'Reschedule Interval', 'time'). - param('reschedule_on_error', 'Reschedule On Error', 'boolean'). - param('reschedule_times', 'Reschedule Times', 'pint32'). - param('run', 'Run', 'string_list'). - param('run_after_failed_job', 'Run After Failed Job', 'runscript_short'). - param('run_after_job', 'Run After Job', 'runscript_short'). - param('run_before_job', 'Run Before Job', 'runscript_short'). - param('run_script', 'Run Script', 'runscript'). - param('save_file_history', 'Save File History', 'boolean'). - param('schedule_res', 'Schedule', 'res'). - param('sd_plugin_options', 'Sd Plugin Options', 'string_list'). - param('selection_pattern', 'Selection Pattern', 'string'). - param('selection_type', 'Selection Type', 'migration_type'). - param('spool_attributes', 'Spool Attributes', 'boolean'). - param('spool_data', 'Spool Data', 'boolean'). - param('spool_size', 'Spool Size', 'size64'). - param('storage', 'Storage', 'resource_list'). - param('strip_prefix', 'Strip Prefix', 'string'). - param('type', 'Type', 'job_type'). - param('virtual_full_backup_pool', 'Virtual Full Backup Pool', 'res'). - param('where', 'Where', 'directory'). - param('write_bootstrap', 'Write Bootstrap', 'directory'). - param('write_verify_list', 'Write Verify List', 'directory') - - let(:params) { res.params } - # required resources - let(:pre_condition) do - ' - bareos::director::pool { "name": } - bareos::director::catalog { "name": - db_driver => "sqlite3", - db_name => "test", - } - bareos::director::storage { "name": - address => "127.0.0.1", - device => "Device", - media_type => "File", - password => "pw", - } - bareos::director::client { "name": - address => "127.0.0.1", - password => "pw", - } - bareos::director::fileset { "name": } - bareos::director::schedule { "name": } - bareos::director::messages { "name": } - bareos::director::job { "name2": - messages => "name", - pool => "name", - type => "backup", - } - bareos::director::jobdefs { "name2": } - ' - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-dir]'). - that_requires('Bareos::Director::Catalog[name]'). - that_requires('Bareos::Director::Storage[name]'). - that_requires('Bareos::Director::Schedule[name]'). - that_requires('Bareos::Director::Messages[name]'). - that_requires('Bareos::Director::Client[name]'). - that_requires('Bareos::Director::Fileset[name]'). - that_requires('Bareos::Director::Job[name2]'). - that_requires('Bareos::Director::Jobdefs[name2]'). - that_requires('Bareos::Director::Pool[name]') - end - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/director/director_messages_spec.rb b/spec/defines/director/director_messages_spec.rb deleted file mode 100644 index 7ce888a..0000000 --- a/spec/defines/director/director_messages_spec.rb +++ /dev/null @@ -1,62 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::director::messages' do - let(:title) { 'name' } - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - filename = '/etc/bareos/bareos-dir.d/messages/name.conf' - - context 'with default values for all parameters' do - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::director') } - it { is_expected.to contain_file(filename).with_content(%r{^Messages \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_director]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Messages') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('append', 'Append', 'messages_list'). - param('catalog', 'Catalog', 'messages_list'). - param('console', 'Console', 'messages_list'). - param('director', 'Director', 'messages_list'). - param('file', 'File', 'messages_list'). - param('mail_command', 'Mail Command', 'string'). - param('mail', 'Mail', 'messages_list'). - param('mail_on_error', 'Mail On Error', 'messages_list'). - param('mail_on_success', 'Mail On Success', 'messages_list'). - param('operator_command', 'Operator Command', 'string'). - param('operator', 'Operator', 'messages_list'). - param('stderr', 'Stderr', 'messages_list'). - param('stdout', 'Stdout', 'messages_list'). - param('syslog', 'Syslog', 'messages_list'). - param('timestamp_format', 'Timestamp Format', 'string') - - let(:params) { res.params } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-dir]') - end - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/director/director_pool_spec.rb b/spec/defines/director/director_pool_spec.rb deleted file mode 100644 index 7f4dbb3..0000000 --- a/spec/defines/director/director_pool_spec.rb +++ /dev/null @@ -1,98 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::director::pool' do - let(:title) { 'name' } - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - filename = '/etc/bareos/bareos-dir.d/pool/name.conf' - - context 'with default values for all parameters' do - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::director') } - it { is_expected.to contain_file(filename).with_content(%r{^Pool \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_director]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Pool') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('action_on_purge', 'Action On Purge', 'action_on_purge'). - param('auto_prune', 'Auto Prune', 'boolean'). - param('catalog', 'Catalog', 'res'). - param('catalog_files', 'Catalog Files', 'boolean'). - param('cleaning_prefix', 'Cleaning Prefix', 'strname'). - param('file_retention', 'File Retention', 'time'). - param('job_retention', 'Job Retention', 'time'). - param('label_format', 'Label Format', 'strname'). - param('label_type', 'Label Type', 'label'). - param('maximum_block_size', 'Maximum Block Size', 'pint32'). - param('maximum_volume_bytes', 'Maximum Volume Bytes', 'size64'). - param('maximum_volume_files', 'Maximum Volume Files', 'pint32'). - param('maximum_volume_jobs', 'Maximum Volume Jobs', 'pint32'). - param('maximum_volumes', 'Maximum Volumes', 'pint32'). - param('migration_high_bytes', 'Migration High Bytes', 'size64'). - param('migration_low_bytes', 'Migration Low Bytes', 'size64'). - param('migration_time', 'Migration Time', 'time'). - param('minimum_block_size', 'Minimum Block Size', 'pint32'). - param('next_pool', 'Next Pool', 'res').param_val('next_pool', 'next_pool', '"next_pool"'). - param('pool_type', 'Pool Type', 'pooltype'). - param('purge_oldest_volume', 'Purge Oldest Volume', 'boolean'). - param('recycle', 'Recycle', 'boolean'). - param('recycle_current_volume', 'Recycle Current Volume', 'boolean'). - param('recycle_oldest_volume', 'Recycle Oldest Volume', 'boolean'). - param('recycle_pool', 'Recycle Pool', 'res').param_val('recycle_pool', 'recycle_pool', '"recycle_pool"'). - param('scratch_pool', 'Scratch Pool', 'res').param_val('scratch_pool', 'scratch_pool', '"scratch_pool"'). - param('storage', 'Storage', 'resource_list'). - param('use_catalog', 'Use Catalog', 'boolean'). - param('volume_retention', 'Volume Retention', 'time'). - param('volume_use_duration', 'Volume Use Duration', 'time') - - let(:params) { res.params } - # required resources - let(:pre_condition) do - ' - bareos::director::pool { ["next_pool", "recycle_pool", "scratch_pool"]: } - bareos::director::catalog { "name": - db_driver => "sqlite3", - db_name => "test", - } - bareos::director::storage { "name": - address => "127.0.0.1", - device => "Device", - media_type => "File", - password => "pw", - } - ' - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-dir]'). - that_requires('Bareos::Director::Catalog[name]'). - that_requires('Bareos::Director::Storage[name]'). - that_requires('Bareos::Director::Pool[next_pool]'). - that_requires('Bareos::Director::Pool[recycle_pool]'). - that_requires('Bareos::Director::Pool[scratch_pool]') - end - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/director/director_profile_spec.rb b/spec/defines/director/director_profile_spec.rb deleted file mode 100644 index 8177813..0000000 --- a/spec/defines/director/director_profile_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::director::profile' do - let(:title) { 'name' } - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - filename = '/etc/bareos/bareos-dir.d/profile/name.conf' - - context 'with default values for all parameters' do - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::director') } - it { is_expected.to contain_file(filename).with_content(%r{^Profile \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_director]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Profile') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('catalog_acl', 'Catalog ACL', 'acl'). - param('client_acl', 'Client ACL', 'acl'). - param('command_acl', 'Command ACL', 'acl'). - param('file_set_acl', 'File Set ACL', 'acl'). - param('job_acl', 'Job ACL', 'acl'). - param('plugin_options_acl', 'Plugin Options ACL', 'acl'). - param('pool_acl', 'Pool ACL', 'acl'). - param('schedule_acl', 'Schedule ACL', 'acl'). - param('storage_acl', 'Storage ACL', 'acl'). - param('where_acl', 'Where ACL', 'acl') - - let(:params) { res.params } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-dir]') - end - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/director/director_schedule_spec.rb b/spec/defines/director/director_schedule_spec.rb deleted file mode 100644 index ded8262..0000000 --- a/spec/defines/director/director_schedule_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::director::schedule' do - let(:title) { 'name' } - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - filename = '/etc/bareos/bareos-dir.d/schedule/name.conf' - - context 'with default values for all parameters' do - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::director') } - it { is_expected.to contain_file(filename).with_content(%r{^Schedule \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_director]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Schedule') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('enabled', 'Enabled', 'boolean'). - param('run', 'Run', 'schedule_run_command_list') - - let(:params) { res.params } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-dir]') - end - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/director/director_storage_spec.rb b/spec/defines/director/director_storage_spec.rb deleted file mode 100644 index 9db2907..0000000 --- a/spec/defines/director/director_storage_spec.rb +++ /dev/null @@ -1,104 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::director::storage' do - let(:title) { 'name' } - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - filename = '/etc/bareos/bareos-dir.d/storage/name.conf' - - context 'with default values for all parameters will fail' do - it { is_expected.to compile.and_raise_error(%r{.*}) } - end - - context 'with required values' do - let(:params) do - { - 'address' => '127.0.0.1', - 'device' => 'Device', - 'media_type' => 'File', - 'password' => 'pw' - } - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::director') } - it { is_expected.to contain_file(filename).with_content(%r{^Storage \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_director]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Storage') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('address', 'Address', 'string'). - param('allow_compression', 'Allow Compression', 'boolean'). - param('auth_type', 'Auth Type', 'auth_type'). - param('auto_changer', 'Auto Changer', 'boolean'). - param('cache_status_interval', 'Cache Status Interval', 'time'). - param('changer_device', 'Changer Device', 'strname'). - param('collect_statistics', 'Collect Statistics', 'boolean'). - param('device', 'Device', 'resource_list'). - param('enabled', 'Enabled', 'boolean'). - param('heartbeat_interval', 'Heartbeat Interval', 'time'). - param('maximum_bandwidth_per_job', 'Maximum Bandwidth Per Job', 'speed'). - param('maximum_concurrent_jobs', 'Maximum Concurrent Jobs', 'pint32'). - param('maximum_concurrent_read_jobs', 'Maximum Concurrent Read Jobs', 'pint32'). - param('media_type', 'Media Type', 'strname'). - param('paired_storage', 'Paired Storage', 'res').param_val('paired_storage', 'name2', '"name2"'). - param('password', 'Password', 'autopassword'). - param('port', 'Port', 'pint32'). - param('protocol', 'Protocol', 'auth_protocol_type'). - param('tape_device', 'Tape Device', 'string_list'). - param('tls_allowed_cn', 'Tls Allowed Cn', 'string_list'). - param('tls_authenticate', 'Tls Authenticate', 'boolean'). - param('tls_ca_certificate_dir', 'Tls Ca Certificate Dir', 'directory'). - param('tls_ca_certificate_file', 'Tls Ca Certificate File', 'directory'). - param('tls_certificate', 'Tls Certificate', 'directory'). - param('tls_certificate_revocation_list', 'Tls Certificate Revocation List', 'directory'). - param('tls_cipher_list', 'Tls Cipher List', 'string'). - param('tls_dh_file', 'Tls Dh File', 'directory'). - param('tls_enable', 'Tls Enable', 'boolean'). - param('tls_key', 'Tls Key', 'directory'). - param('tls_require', 'Tls Require', 'boolean'). - param('tls_verify_peer', 'Tls Verify Peer', 'boolean'). - param('username', 'Username', 'string') - - let(:params) { res.params } - # required resources - let(:pre_condition) do - ' - bareos::director::storage { "name2": - address => "127.0.0.1", - device => "Device", - media_type => "File", - password => "pw", - } - ' - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-dir]'). - that_requires('Bareos::Director::Storage[name2]') - end - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/monitor/monitor_client_spec.rb b/spec/defines/monitor/monitor_client_spec.rb deleted file mode 100644 index 5aff28f..0000000 --- a/spec/defines/monitor/monitor_client_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::monitor::client' do - let(:title) { 'name' } - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - filename = '/etc/bareos/tray-monitor.d/client/name.conf' - - context 'with default values for all parameters will fail' do - it { is_expected.to compile.and_raise_error(%r{.*}) } - end - - context 'with required values' do - let(:params) do - { - 'password' => 'password', - 'address' => 'localhost' - } - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::monitor') } - it { is_expected.to contain_file(filename).with_content(%r{^Client \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_monitor]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Client') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('address', 'Address', 'string'). - param('enable_ssl', 'Enable Ssl', 'boolean'). - param('fd_port', 'Fd Port', 'pint32'). - param('password', 'Password', 'md5password') - - let(:params) { res.params } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/monitor/monitor_director_spec.rb b/spec/defines/monitor/monitor_director_spec.rb deleted file mode 100644 index 4a68081..0000000 --- a/spec/defines/monitor/monitor_director_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::monitor::director' do - let(:title) { 'name' } - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - filename = '/etc/bareos/tray-monitor.d/director/name.conf' - - context 'with default values for all parameters will fail' do - it { is_expected.to compile.and_raise_error(%r{.*}) } - end - - context 'with required values' do - let(:params) do - { - 'address' => 'localhost' - } - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::monitor') } - it { is_expected.to contain_file(filename).with_content(%r{^Director \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_monitor]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Director') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('address', 'Address', 'string'). - param('dir_port', 'Dir Port', 'pint32'). - param('enable_ssl', 'Enable Ssl', 'boolean') - - let(:params) { res.params } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/monitor/monitor_monitor_spec.rb b/spec/defines/monitor/monitor_monitor_spec.rb deleted file mode 100644 index 12ec0c1..0000000 --- a/spec/defines/monitor/monitor_monitor_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::monitor::monitor' do - let(:title) { 'name' } - - filename = '/etc/bareos/tray-monitor.d/monitor/name.conf' - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - context 'with default values for all parameters will fail' do - it { is_expected.to compile.and_raise_error(%r{.*}) } - end - - context 'with required values' do - let(:params) do - { - 'password' => 'password' - } - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::monitor') } - it { is_expected.to contain_file(filename).with_content(%r{^Monitor \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_monitor]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Monitor') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('dir_connect_timeout', 'Dir Connect Timeout', 'time'). - param('fd_connect_timeout', 'Fd Connect Timeout', 'time'). - param('password', 'Password', 'md5password'). - param('refresh_interval', 'Refresh Interval', 'time'). - param('require_ssl', 'Require Ssl', 'boolean'). - param('sd_connect_timeout', 'Sd Connect Timeout', 'time') - - let(:params) { res.params } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/monitor/monitor_storage_spec.rb b/spec/defines/monitor/monitor_storage_spec.rb deleted file mode 100644 index f134079..0000000 --- a/spec/defines/monitor/monitor_storage_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::monitor::storage' do - let(:title) { 'name' } - - filename = '/etc/bareos/tray-monitor.d/storage/name.conf' - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - context 'with default values for all parameters will fail' do - it { is_expected.to compile.and_raise_error(%r{.*}) } - end - - context 'with required values' do - let(:params) do - { - 'password' => 'password', - 'address' => 'localhost' - } - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::monitor') } - it { is_expected.to contain_file(filename).with_content(%r{^Storage \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_monitor]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Storage') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('address', 'Address', 'string'). - param('enable_ssl', 'Enable Ssl', 'boolean'). - param('password', 'Password', 'md5password'). - param('sd_address', 'Sd Address', 'string'). - param('sd_password', 'Sd Password', 'md5password'). - param('sd_port', 'Sd Port', 'pint32') - - let(:params) { res.params } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/storage/storage_autochanger_spec.rb b/spec/defines/storage/storage_autochanger_spec.rb deleted file mode 100644 index aef30a7..0000000 --- a/spec/defines/storage/storage_autochanger_spec.rb +++ /dev/null @@ -1,83 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::storage::autochanger' do - let :node do - 'rspec.puppet.com' - end - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - let(:title) { 'name' } - - filename = '/etc/bareos/bareos-sd.d/autochanger/name.conf' - - context 'with default values for all parameters will fail' do - it { is_expected.to compile.and_raise_error(%r{.*}) } - end - - context 'with required values' do - let(:params) do - { - 'changer_command' => '/bin/command', - 'changer_device' => '/dev/tape', - 'device' => 'name' - } - end - let(:pre_condition) do - ' - bareos::storage::device { "name": - archive_device => "/dev/tape", - media_type => "DLT7000" - } - ' - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::storage') } - it { is_expected.to contain_file(filename).with_content(%r{^Autochanger \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_storage]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Autochanger') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('changer_command', 'Changer Command', 'strname'). - param('changer_device', 'Changer Device', 'strname'). - param('device', 'Device', 'resource_list') - - let(:params) { res.params } - # required resources - let(:pre_condition) do - ' - bareos::storage::device { "name": - archive_device => "/dev/tape", - media_type => "DLT7000" - } - ' - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-sd]'). - that_requires('Bareos::Storage::Device[name]') - end - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/storage/storage_device_spec.rb b/spec/defines/storage/storage_device_spec.rb deleted file mode 100644 index 7fbb8ef..0000000 --- a/spec/defines/storage/storage_device_spec.rb +++ /dev/null @@ -1,119 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::storage::device' do - let(:title) { 'name' } - - filename = '/etc/bareos/bareos-sd.d/device/name.conf' - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - context 'with default values for all parameters will fail' do - it { is_expected.to compile.and_raise_error(%r{.*}) } - end - - context 'with required values' do - let(:params) do - { - 'archive_device' => '/dev/tape', - 'media_type' => 'DLT7000' - } - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::storage') } - it { is_expected.to contain_file(filename).with_content(%r{^Device \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_storage]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Device') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('alert_command', 'Alert Command', 'strname'). - param('always_open', 'Always Open', 'bit'). - param('archive_device', 'Archive Device', 'strname'). - param('auto_deflate', 'Auto Deflate', 'io_direction'). - param('auto_deflate_algorithm', 'Auto Deflate Algorithm', 'compression_algorithm'). - param('auto_deflate_level', 'Auto Deflate Level', 'pint16'). - param('auto_inflate', 'Auto Inflate', 'io_direction'). - param('auto_select', 'Auto Select', 'boolean'). - param('autochanger', 'Autochanger', 'bit'). - param('automatic_mount', 'Automatic Mount', 'bit'). - param('backward_space_file', 'Backward Space File', 'bit'). - param('backward_space_record', 'Backward Space Record', 'bit'). - param('block_checksum', 'Block Checksum', 'bit'). - param('block_positioning', 'Block Positioning', 'bit'). - param('bsf_at_eom', 'Bsf At Eom', 'bit'). - param('changer_command', 'Changer Command', 'strname'). - param('changer_device', 'Changer Device', 'strname'). - param('check_labels', 'Check Labels', 'bit'). - param('close_on_poll', 'Close On Poll', 'bit'). - param('collect_statistics', 'Collect Statistics', 'boolean'). - param('count', 'Count', 'pint32'). - param('device_options', 'Device Options', 'string'). - param('device_type', 'Device Type', 'device_type'). - param('diagnostic_device', 'Diagnostic Device', 'strname'). - param('drive_crypto_enabled', 'Drive Crypto Enabled', 'boolean'). - param('drive_index', 'Drive Index', 'pint16'). - param('drive_tape_alert_enabled', 'Drive Tape Alert Enabled', 'boolean'). - param('fast_forward_space_file', 'Fast Forward Space File', 'bit'). - param('forward_space_file', 'Forward Space File', 'bit'). - param('forward_space_record', 'Forward Space Record', 'bit'). - param('hardware_end_of_file', 'Hardware End Of File', 'bit'). - param('hardware_end_of_medium', 'Hardware End Of Medium', 'bit'). - param('label_block_size', 'Label Block Size', 'pint32'). - param('label_media', 'Label Media', 'bit'). - param('label_type', 'Label Type', 'label'). - param('maximum_block_size', 'Maximum Block Size', 'max_blocksize'). - param('maximum_changer_wait', 'Maximum Changer Wait', 'time'). - param('maximum_concurrent_jobs', 'Maximum Concurrent Jobs', 'pint32'). - param('maximum_file_size', 'Maximum File Size', 'size64'). - param('maximum_job_spool_size', 'Maximum Job Spool Size', 'size64'). - param('maximum_network_buffer_size', 'Maximum Network Buffer Size', 'pint32'). - param('maximum_open_volumes', 'Maximum Open Volumes', 'pint32'). - param('maximum_open_wait', 'Maximum Open Wait', 'time'). - param('maximum_rewind_wait', 'Maximum Rewind Wait', 'time'). - param('maximum_spool_size', 'Maximum Spool Size', 'size64'). - param('media_type', 'Media Type', 'strname'). - param('minimum_block_size', 'Minimum Block Size', 'pint32'). - param('mount_command', 'Mount Command', 'strname'). - param('mount_point', 'Mount Point', 'strname'). - param('no_rewind_on_close', 'No Rewind On Close', 'boolean'). - param('offline_on_unmount', 'Offline On Unmount', 'bit'). - param('query_crypto_status', 'Query Crypto Status', 'boolean'). - param('random_access', 'Random Access', 'bit'). - param('removable_media', 'Removable Media', 'bit'). - param('requires_mount', 'Requires Mount', 'bit'). - param('spool_directory', 'Spool Directory', 'directory'). - param('two_eof', 'Two Eof', 'bit'). - param('unmount_command', 'Unmount Command', 'strname'). - param('use_mtiocget', 'Use Mtiocget', 'bit'). - param('volume_capacity', 'Volume Capacity', 'size64'). - param('volume_poll_interval', 'Volume Poll Interval', 'time') - - let(:params) { res.params } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-sd]') - end - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/storage/storage_director_spec.rb b/spec/defines/storage/storage_director_spec.rb deleted file mode 100644 index f4854e7..0000000 --- a/spec/defines/storage/storage_director_spec.rb +++ /dev/null @@ -1,76 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::storage::director' do - let :node do - 'rspec.puppet.com' - end - let(:title) { 'name' } - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - filename = '/etc/bareos/bareos-sd.d/director/name.conf' - - context 'with default values for all parameters will fail' do - it { is_expected.to compile.and_raise_error(%r{.*}) } - end - - context 'with required values' do - let(:params) do - { - 'password' => 'pw' - } - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::storage') } - it { is_expected.to contain_file(filename).with_content(%r{^Director \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_storage]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Director') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('key_encryption_key', 'Key Encryption Key', 'autopassword'). - param('maximum_bandwidth_per_job', 'Maximum Bandwidth Per Job', 'speed'). - param('monitor', 'Monitor', 'boolean'). - param('password', 'Password', 'autopassword'). - param('tls_allowed_cn', 'Tls Allowed Cn', 'string_list'). - param('tls_authenticate', 'Tls Authenticate', 'boolean'). - param('tls_ca_certificate_dir', 'Tls Ca Certificate Dir', 'directory'). - param('tls_ca_certificate_file', 'Tls Ca Certificate File', 'directory'). - param('tls_certificate', 'Tls Certificate', 'directory'). - param('tls_certificate_revocation_list', 'Tls Certificate Revocation List', 'directory'). - param('tls_cipher_list', 'Tls Cipher List', 'string'). - param('tls_dh_file', 'Tls Dh File', 'directory'). - param('tls_enable', 'Tls Enable', 'boolean'). - param('tls_key', 'Tls Key', 'directory'). - param('tls_require', 'Tls Require', 'boolean'). - param('tls_verify_peer', 'Tls Verify Peer', 'boolean') - - let(:params) { res.params } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-sd]') - end - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/storage/storage_messages_spec.rb b/spec/defines/storage/storage_messages_spec.rb deleted file mode 100644 index e218889..0000000 --- a/spec/defines/storage/storage_messages_spec.rb +++ /dev/null @@ -1,62 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::storage::messages' do - let(:title) { 'name' } - - filename = '/etc/bareos/bareos-sd.d/messages/name.conf' - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - context 'with default values for all parameters' do - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::storage') } - it { is_expected.to contain_file(filename).with_content(%r{^Messages \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_storage]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Messages') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('append', 'Append', 'messages_list'). - param('catalog', 'Catalog', 'messages_list'). - param('console', 'Console', 'messages_list'). - param('director', 'Director', 'messages_list'). - param('file', 'File', 'messages_list'). - param('mail_command', 'Mail Command', 'string'). - param('mail', 'Mail', 'messages_list'). - param('mail_on_error', 'Mail On Error', 'messages_list'). - param('mail_on_success', 'Mail On Success', 'messages_list'). - param('operator_command', 'Operator Command', 'string'). - param('operator', 'Operator', 'messages_list'). - param('stderr', 'Stderr', 'messages_list'). - param('stdout', 'Stdout', 'messages_list'). - param('syslog', 'Syslog', 'messages_list'). - param('timestamp_format', 'Timestamp Format', 'string') - - let(:params) { res.params } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-sd]') - end - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/defines/storage/storage_ndmp_spec.rb b/spec/defines/storage/storage_ndmp_spec.rb deleted file mode 100644 index c64c9a6..0000000 --- a/spec/defines/storage/storage_ndmp_spec.rb +++ /dev/null @@ -1,66 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -describe 'bareos::storage::ndmp' do - let :node do - 'rspec.puppet.com' - end - - on_supported_os.each do |os, facts| - context "on #{os}" do - let :facts do - facts - end - - let(:title) { 'name' } - - filename = '/etc/bareos/bareos-sd.d/ndmp/name.conf' - - context 'with default values for all parameters will fail' do - it { is_expected.to compile.and_raise_error(%r{.*}) } - end - - context 'with required values' do - let(:params) do - { - 'username' => 'user', - 'password' => 'pw' - } - end - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_class('bareos::storage') } - it { is_expected.to contain_file(filename).with_content(%r{^Ndmp \{$}) } - it { is_expected.to contain_file(filename).with_content(%r{Name = "name"$}) } - it { is_expected.to contain_file(filename).with_tag(%w[bareos bareos_storage]) } - end - - context 'with all params set' do - res = BareosResourceHelper.new('Ndmp') - res.param('name', 'Name', 'name'). - param('description', 'Description', 'string'). - param('auth_type', 'Auth Type', 'auth_type'). - param('log_level', 'Log Level', 'pint32'). - param('password', 'Password', 'autopassword'). - param('username', 'Username', 'string') - - let(:params) { res.params } - - it { is_expected.to compile.with_all_deps } - it { is_expected.to contain_file(filename).with_content(res.content) } - - it do - expect(subject).to contain_file(filename). - that_notifies('Service[bareos-sd]') - end - end - - context 'with ensure absent' do - let(:params) { { 'ensure' => 'absent' } } - - it { is_expected.to contain_file(filename).with_ensure('absent') } - end - end - end -end diff --git a/spec/functions/bareos_settings_spec.rb b/spec/functions/bareos_settings_spec.rb deleted file mode 100644 index f432d66..0000000 --- a/spec/functions/bareos_settings_spec.rb +++ /dev/null @@ -1,444 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' -indent_default = ' ' - -describe 'bareos_settings' do - context 'type is an integer' do - %w[int32 pint16 pint32 port max_blocksize].each do |type| - it 'runs with compatible values' do - [0, 1, 3849, 222, '2'].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = #{val}") - end - end - - it 'not runs with incompatible values' do - ['string', { 'hash' => 'val' }].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is a resource name' do - %w[name res resource].each do |type| - it 'runs with compatible values and is quoted' do - ['This is an string', 'combatible Res_Name-7.9', 'a' * 127].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = \"#{val}\"") - end - end - - it 'not runs with incompatible values' do - ['0 number start', ' space', '.point', 'a' * 128].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is a string without quotes' do - %w[acl messages type string_noquote schedule_run_command].each do |type| - it 'runs with compatible values' do - ['Not a number', 'MyString', '23 free usage of Text.!', 'Special ".-,= Chars'].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = #{val}") - end - end - - it 'not runs with incompatible values' do - [0, -1, 2, { 'hash' => 'val' }].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is a string with quotes' do - %w[audit_command autopassword md5password directory string strname device plugin_names].each do |type| - it 'runs with compatible values' do - ['Not a number', 'MyString', '23 free usage of Text.!', 'Special ".-,= Chars'].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = \"#{val}\"") - end - end - - it 'not runs with incompatible values' do - [0, -1, 2, { 'hash' => 'val' }, %w[array of string]].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is speed' do - %w[speed].each do |type| - it 'runs with compatible values' do - ['0 k/s', '49Kb/s', '1 m/s', '200MB/s'].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = #{val}") - end - end - - it 'not runs with incompatible values' do - ['M', 50, 'k/s', '', ' '].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is size' do - %w[size64].each do |type| - it 'runs with compatible values' do - ['6k', '400 KB', '5083 m', '100g', '10 GB'].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = #{val}") - end - end - - it 'not runs with incompatible values' do - ['M', 50, 'GB', '', ' '].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - # add time - - context 'type is boolean' do - %w[boolean bit].each do |type| - it 'runs with compatible values' do - ['yes', 'NO', 'on', 'OFF', 'TRUE', 'false', true, false].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = #{val}") - end - end - - it 'not runs with incompatible values' do - [0, 1, 'true s', 'false s'].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is a address' do - %w[address].each do |type| - it 'runs with compatible values' do - ['10.0.0.1', '88.120.0.4', '2001:22::f4', 'fd00:0000:0000:0000::1', 'fancy.domain.com', 'my.host.name.de'].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = #{val}") - end - end - - it 'not runs with incompatible values' do - [0, true, { 'hash' => 'val' }, 'ff01::1::2', 'my domain com', ' invalid,char.com'].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is an hashed addresses value' do - %w[addresses].each do |type| - it 'runs with compatible values' do - val = { - 'ip' => { - 'addr' => '1.2.3.4', - 'port' => '1205' - } - } - result = "#{indent_default}Test = { -#{indent_default}#{indent_default}ip = { -#{indent_default}#{indent_default}#{indent_default}addr = 1.2.3.4 -#{indent_default}#{indent_default}#{indent_default}port = 1205 -#{indent_default}#{indent_default}} -#{indent_default}}" - expect(subject).to run.with_params([val, 'Test', type, true]).and_return(result) - end - - it 'not runs with incompatible values' do - ['wrong', 222, ['array'], false, true].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is an hashed value' do - %w[include_exclude_item runscript hash].each do |type| - it 'runs with compatible values' do - val = { - 'My Directive' => 'content', - 'Array' => %w[a1 b2], - 'Second Hash' => { - 'Res' => 'Val' - } - } - result = "#{indent_default}Test { -#{indent_default}#{indent_default}My Directive = content -#{indent_default}#{indent_default}Array = a1 -#{indent_default}#{indent_default}Array = b2 -#{indent_default}#{indent_default}Second Hash { -#{indent_default}#{indent_default}#{indent_default}Res = Val -#{indent_default}#{indent_default}} -#{indent_default}}" - expect(subject).to run.with_params([val, 'Test', type, true]).and_return(result) - end - - it 'not runs with incompatible values' do - ['wrong', 222, ['array'], false, true].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is backup_level' do - %w[backup_level].each do |type| - it 'runs with compatible values' do - %w[Full incremental differential VirtualFull].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = #{val}") - end - end - - it 'not runs with incompatible values' do - ['wrong', 'fully', ' Full'].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is io_direction' do - %w[io_direction].each do |type| - it 'runs with compatible values' do - %w[in out BOTH].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = #{val}") - end - end - - it 'not runs with incompatible values' do - ['wrong', ' in'].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is action_on_purge' do - %w[action_on_purge].each do |type| - it 'runs with compatible values' do - %w[truncate Truncate].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = #{val}") - end - end - - it 'not runs with incompatible values' do - ['wrong', ' truncate'].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is encryption_cipher' do - %w[encryption_cipher].each do |type| - it 'runs with compatible values' do - %w[aes128 AES192 aes256 camellia128 camellia192 camellia256 aes128hmacsha1 aes256hmacsha1 blowfish].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = #{val}") - end - end - - it 'not runs with incompatible values' do - ['wrong', ' aes'].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is auth_type' do - %w[auth_type].each do |type| - it 'runs with compatible values' do - %w[clear MD5].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = #{val}") - end - end - - it 'not runs with incompatible values' do - ['wrong', ' clear'].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is auth_protocol_type' do - %w[auth_protocol_type].each do |type| - it 'runs with compatible values' do - %w[native NDMP].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = #{val}") - end - end - - it 'not runs with incompatible values' do - ['wrong', ' ndmp'].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is pooltype' do - %w[pooltype].each do |type| - it 'runs with compatible values' do - %w[backup ARCHIVE cloned migration copy save scratch].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = #{val}") - end - end - - it 'not runs with incompatible values' do - ['wrong', ' backup'].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is label' do - %w[label].each do |type| - it 'runs with compatible values' do - %w[ansi IBM bareos].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = #{val}") - end - end - - it 'not runs with incompatible values' do - ['wrong', ' bareos'].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is migration_type' do - %w[migration_type].each do |type| - it 'runs with compatible values' do - %w[smallestvolume oldestvolume client volume Job sqlquery pooloccupancy pooltime pooluncopiedjobs].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = #{val}") - end - end - - it 'not runs with incompatible values' do - ['wrong', ' JOB'].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is job_type' do - %w[job_type].each do |type| - it 'runs with compatible values' do - %w[backup restore verify ADMIN migrate copy consolidate].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = #{val}") - end - end - - it 'not runs with incompatible values' do - ['wrong', ' backup'].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is replace_option' do - %w[replace_option].each do |type| - it 'runs with compatible values' do - %w[Always ifnewer ifolder never].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = #{val}") - end - end - - it 'not runs with incompatible values' do - ['wrong', ' never'].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is device_type' do - %w[device_type].each do |type| - it 'runs with compatible values' do - %w[TAPE file fifo gfapi rados].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = #{val}") - end - end - - it 'not runs with incompatible values' do - ['wrong', ' File'].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is compression_algorithm' do - %w[compression_algorithm].each do |type| - it 'runs with compatible values' do - %w[GZIP LZO lzfast lz4 lz4hc].each do |val| - expect(subject).to run.with_params([val, 'Test', type, true]).and_return("#{indent_default}Test = #{val}") - end - end - - it 'not runs with incompatible values' do - ['wrong', ' gzip'].each do |val| - expect(subject).not_to run.with_params([val, 'Test', type, true]) - end - end - end - end - - context 'type is not compatible' do - %w[invalid doesNotExist really_not_exists].each do |type| - it 'raise error' do - expect(subject).to run.with_params([1, 'Test', type, true]).and_raise_error(Puppet::ParseError, %r{Invalid setting type}) - end - end - end - - context 'value can be an array' do - it 'any type with _list suffix' do - val = %w[first second] - result = "#{indent_default}Test = first -#{indent_default}Test = second" - expect(subject).to run.with_params([val, 'Test', 'string_noquote_list', true]).and_return(result) - end - - it 'type is runscript_short' do - val = %w[first second] - result = "#{indent_default}Test = \"first\" -#{indent_default}Test = \"second\"" - expect(subject).to run.with_params([val, 'Test', 'runscript_short', true]).and_return(result) - end - - it 'type is acl' do - val = %w[first second] - result = "#{indent_default}Test = first -#{indent_default}Test = second" - expect(subject).to run.with_params([val, 'Test', 'acl', true]).and_return(result) - end - - it 'type is runscript' do - val = [ - { 'Test A' => 'value' }, - { 'Test B' => 'value' } - ] - result = "#{indent_default}Test { -#{indent_default}#{indent_default}Test A = value -#{indent_default}} -#{indent_default}Test { -#{indent_default}#{indent_default}Test B = value -#{indent_default}}" - expect(subject).to run.with_params([val, 'Test', 'runscript', true]).and_return(result) - end - end -end diff --git a/spec/helper/get_defaults.rb b/spec/helper/get_defaults.rb new file mode 100644 index 0000000..5366663 --- /dev/null +++ b/spec/helper/get_defaults.rb @@ -0,0 +1,91 @@ +def get_defaults(_facts) + ## + ## basic settings + ## + config_directory = '/etc/bareos' + config_directory_mode = '0755' + config_file_mode = '0660' + config_group = 'bareos' + config_owner = 'bareos' + manage_user = true + + ## + ## repository settings + ## + manage_repository = true + repository_host = :undef + repository_key = {} + repository_password = :undef + repository_release = '20' + repository_ssl = true + repository_subscription = false + repository_username = :undef + + ## + ## client settings + ## + enable_client = true + manage_client_package = true + manage_client_service = true + client_config = {} + client_config_directory = 'bareos-fd.d' + client_packages = [ + 'bareos-filedaemon', + 'bareos-filedaemon-python-plugin', + ] + client_package_ensure = 'present' + client_service_enable = true + client_service_ensure = 'running' + client_service = 'bareos-fd' + + ## + ## console + ## + manage_console_package = true + console_packages = [ 'bareos-bconsole', ] + console_package_ensure = 'present' + + ## + ## monitor + ## + manage_monitor_package = true + monitor_packages = [ 'bareos-traymonitor', ] + monitor_package_ensure = 'present' + + { + 'config_directory_mode' => config_directory_mode, + 'config_directory' => config_directory, + 'config_file_mode' => config_file_mode, + 'config_group' => config_group, + 'config_owner' => config_owner, + 'manage_user' => manage_user, + + 'manage_repository' => manage_repository, + 'repository_host' => repository_host, + 'repository_key' => repository_key, + 'repository_password' => repository_password, + 'repository_release' => repository_release, + 'repository_ssl' => repository_ssl, + 'repository_subscription' => repository_subscription, + 'repository_username' => repository_username, + + 'enable_client' => enable_client, + 'manage_client_package' => manage_client_package, + 'manage_client_service' => manage_client_service, + 'client_config' => client_config, + 'client_config_directory' => client_config_directory, + 'client_packages' => client_packages, + 'client_package_ensure' => client_package_ensure, + 'client_service_enable' => client_service_enable, + 'client_service_ensure' => client_service_ensure, + 'client_service' => client_service, + + 'manage_console_package' => manage_console_package, + 'console_packages' => console_packages, + 'console_package_ensure' => console_package_ensure, + + 'manage_monitor_package' => manage_monitor_package, + 'monitor_packages' => monitor_packages, + 'monitor_package_ensure' => monitor_package_ensure, + } +end diff --git a/spec/settings_helper.rb b/spec/settings_helper.rb deleted file mode 100644 index 79a0012..0000000 --- a/spec/settings_helper.rb +++ /dev/null @@ -1,117 +0,0 @@ -# frozen_string_literal: true - -# Provide some generic helper to test classes/defines for bareos -require 'spec_helper' - -# This simplifies the generic build of the bareos template config checks -class BareosResourceHelper - attr_reader :config, :resource - - def initialize(resource) - @resource = resource - @config = {} - end - - # return params for let - # attr name, directive name and bareos type - def param(attr, directive, type_argument) - result = nil - val = 'not set' - sep = ' = ' - type = type_argument.gsub(%r{([_-]list)$}, '') - - case type - # short hack to have simple res names - when 'name', 'res', 'resource' - val = 'name' - result = '"name"' - # maybe check more than it is an int - when 'int32', 'pint16', 'pint32', 'port', 'max_blocksize' - val = 42 - when 'audit_command', 'runscript_short', 'autopassword', 'md5password', 'directory', 'string', 'strname', 'device', 'plugin_names' - val = 'Example Value' - result = '"Example Value"' - when 'acl', 'messages', 'type', 'string_noquote', 'schedule_run_command' - val = 'Long text without direct "quotes' - when 'speed' - val = '1337 MB/s' - when 'size64' - val = '1337 MB' - when 'time' - val = '1337 sec' - when 'boolean', 'bit' - val = false - when 'address' - val = 'host.name.com' - when 'addresses', 'include_exclude_item', 'runscript', 'hash' - sep = ' ' unless type == 'addresses' - val = { - 'x' => 'y' - } - result = '{ - x = y - }' - when 'backup_level' - val = 'full' - when 'io_direction' - val = 'in' - when 'action_on_purge' - val = 'truncate' - when 'encryption_cipher' - val = 'aes192' - when 'auth_type' - val = 'clear' - when 'auth_protocol_type', 'protocol_type' - val = 'native' - when 'pooltype', 'job_type' - val = 'backup' - when 'label' - val = 'ANSI' - when 'migration_type' - val = 'job' - when 'replace_option' - val = 'always' - when 'device_type' - val = 'file' - when 'compression_algorithm' - val = 'gzip' - else - raise "Missing setting type '#{type}'" - end - - @config[attr] = { - 'dir' => directive, - 'type' => type, - 'val' => val, - 'res' => result.nil? ? val : result, - 'sep' => sep - } - - self - end - - # set custom value - def param_val(attr, val, res) - @config[attr]['val'] = val - @config[attr]['res'] = res - self - end - - # get params for :let - def params - tmp = {} - @config.each do |k, v| - tmp[k] = v['val'] - end - tmp - end - - # build content to compare with created file - def content - tmp = "# This file is managed by puppet\n#{@resource} {\n" - @config.each do |_, v| - tmp = "#{tmp} #{v['dir']}#{v['sep']}#{v['res']}\n" - end - "#{tmp}}\n" - end -end diff --git a/spec/shared_examples.rb b/spec/shared_examples.rb new file mode 100644 index 0000000..8023a7f --- /dev/null +++ b/spec/shared_examples.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require 'shared_examples/client' +require 'shared_examples/client/config' +require 'shared_examples/client/package' +require 'shared_examples/client/service' +require 'shared_examples/config' +require 'shared_examples/console' +require 'shared_examples/monitor' +require 'shared_examples/repository' +require 'shared_examples/repository/apt' +require 'shared_examples/repository/yum' + +require 'helper/get_defaults' diff --git a/spec/shared_examples/client.rb b/spec/shared_examples/client.rb new file mode 100644 index 0000000..f6f4b11 --- /dev/null +++ b/spec/shared_examples/client.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +shared_examples 'client' do |_params, _facts| + it { + is_expected.to contain_class('bareos::client') + } + + it { + is_expected.to contain_class('bareos::client::config').that_notifies('Class[bareos::client::service]') + is_expected.to contain_class('bareos::client::package').that_comes_before('Class[bareos::client::config]').that_notifies('Class[bareos::client::service]') + is_expected.to contain_class('bareos::client::service') + } + + include_examples 'client::config', _params, _facts + include_examples 'client::package', _params, _facts + include_examples 'client::service', _params, _facts +end diff --git a/spec/shared_examples/client/config.rb b/spec/shared_examples/client/config.rb new file mode 100644 index 0000000..b58d804 --- /dev/null +++ b/spec/shared_examples/client/config.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +shared_examples 'client::config' do |_params, _facts| + it { + is_expected.to contain_class('bareos::client::config') + } + + client_config_directory = "#{_params['config_directory']}/#{_params['client_config_directory']}" + + if _params['enable_client'] + it { + is_expected.to contain_file(client_config_directory).with( + { + 'ensure' => 'directory', + 'force' => true, + 'group' => _params['config_group'], + 'mode' => _params['config_directory_mode'], + 'owner' => _params['config_owner'], + 'purge' => true, + 'recurse' => true, + } + ) + } + + [ + "#{client_config_directory}/client", + "#{client_config_directory}/director", + "#{client_config_directory}/messages", + ].each do |client_directory| + it { + is_expected.to contain_file(client_directory).with( + { + 'ensure' => 'directory', + 'group' => _params['config_group'], + 'mode' => _params['config_directory_mode'], + 'owner' => _params['config_owner'], + } + ) + } + end + else + it { + is_expected.to contain_file(client_config_directory).with( + { + 'ensure' => 'absent', + 'force' => true, + 'purge' => true, + 'recurse' => true, + } + ) + } + end + + +end diff --git a/spec/shared_examples/client/package.rb b/spec/shared_examples/client/package.rb new file mode 100644 index 0000000..64b34f7 --- /dev/null +++ b/spec/shared_examples/client/package.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +shared_examples 'client::package' do |_params, _facts| + it { + is_expected.to contain_class('bareos::client::package') + } + + if _params['enable_client'] && _params['manage_client_package'] + _params['client_packages'].each do |client_package| + it { + is_expected.to contain_package(client_package).with( + { + 'ensure' => _params['client_package_ensure'], + } + ) + } + end + else + _params['client_packages'].each do |client_package| + it { + is_expected.not_to contain_package(client_package) + } + end + end +end diff --git a/spec/shared_examples/client/service.rb b/spec/shared_examples/client/service.rb new file mode 100644 index 0000000..9bc0ab3 --- /dev/null +++ b/spec/shared_examples/client/service.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +shared_examples 'client::service' do |_params, _facts| + it { + is_expected.to contain_class('bareos::client::service') + } + + if _params['enable_client'] && _params['manage_client_service'] + it { + is_expected.to contain_service(_params['client_service']).with( + { + 'ensure' => _params['client_service_ensure'], + 'enable' => _params['client_service_enable'], + } + ) + } + else + it { + is_expected.not_to contain_service(_params['client_service']) + } + end +end diff --git a/spec/shared_examples/config.rb b/spec/shared_examples/config.rb new file mode 100644 index 0000000..6c36b32 --- /dev/null +++ b/spec/shared_examples/config.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +shared_examples 'config' do |_params, _facts| + it { + is_expected.to contain_class('bareos::config') + } + + if _params['manage_user'] + it { + is_expected.to contain_group(_params['config_group']).with( + { + 'ensure' => 'present', + 'forcelocal' => true, + 'system' => true, + } + ).that_comes_before("User[#{_params['config_owner']}]") + } + + it { + is_expected.to contain_user(_params['config_owner']).only_with( + { + 'ensure' => 'present', + 'forcelocal' => true, + 'comment' => 'Bareos system user', + 'home' => '/var/lib/bareos', + 'shell' => '/bin/false', + 'groups' => [ + 'disk', + 'tape', + _params['config_group'], + ], + 'system' => true, + } + ) + } + end + + it { + is_expected.to contain_file(_params['config_directory']).only_with( + { + 'ensure' => 'directory', + 'force' => true, + 'group' => _params['config_group'], + 'mode' => _params['config_directory_mode'], + 'owner' => _params['config_owner'], + 'purge' => true, + 'recurse' => true, + 'recurselimit' => 1, + } + ) + } +end diff --git a/spec/shared_examples/console.rb b/spec/shared_examples/console.rb new file mode 100644 index 0000000..604b774 --- /dev/null +++ b/spec/shared_examples/console.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +shared_examples 'console' do |_params, _facts| + it { + is_expected.to contain_class('bareos::console') + } + + if _params['manage_console_package'] + _params['console_packages'].each do |console_package| + it { + is_expected.to contain_package(console_package).with( + 'ensure' => _params['console_package_ensure'], + 'tag' => [ 'bareos', 'bareos_console', ] + ) + } + end + end + + config_console_directories = [ + "#{_params['config_directory']}/bconsole.d", + "#{_params['config_directory']}/bconsole.d/console", + "#{_params['config_directory']}/bconsole.d/director", + ] + + config_console_directories.each do |config_console_directory| + it { + is_expected.to contain_file(config_console_directory).with( + 'ensure' => 'directory', + 'purge' => true, + 'recurse' => true, + 'force' => true, + 'mode' => _params['config_directory_mode'], + 'owner' => _params['config_owner'], + 'group' => _params['config_group'], + 'tag' => [ 'bareos', 'bareos_console', ], + ) + } + end +end diff --git a/spec/shared_examples/monitor.rb b/spec/shared_examples/monitor.rb new file mode 100644 index 0000000..3f20987 --- /dev/null +++ b/spec/shared_examples/monitor.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +shared_examples 'monitor' do |_params, _facts| + it { + is_expected.to contain_class('bareos::monitor') + } + + if _params['manage_monitor_package'] + _params['monitor_packages'].each do |monitor_package| + it { + is_expected.to contain_package(monitor_package).with( + 'ensure' => _params['monitor_package_ensure'], + 'tag' => [ 'bareos', 'bareos_monitor', ] + ) + } + end + end + + config_monitor_directories = [ + "#{_params['config_directory']}/tray-monitor.d", + "#{_params['config_directory']}/tray-monitor.d/client", + "#{_params['config_directory']}/tray-monitor.d/director", + "#{_params['config_directory']}/tray-monitor.d/monitor", + "#{_params['config_directory']}/tray-monitor.d/storage", + ] + + config_monitor_directories.each do |config_monitor_directory| + it { + is_expected.to contain_file(config_monitor_directory).with( + 'ensure' => 'directory', + 'purge' => true, + 'recurse' => true, + 'force' => true, + 'mode' => _params['config_directory_mode'], + 'owner' => _params['config_owner'], + 'group' => _params['config_group'], + 'tag' => [ 'bareos', 'bareos_monitor', ], + ) + } + end +end diff --git a/spec/shared_examples/repository.rb b/spec/shared_examples/repository.rb new file mode 100644 index 0000000..f616f82 --- /dev/null +++ b/spec/shared_examples/repository.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +shared_examples 'repository' do |_params, _facts| + schema = if _params['repository_ssl'] + 'https' + else + 'http' + end + + if _params['repository_subscription'] + if ! _params['repository_username'] or ! _params['repository_password'] + it { + is_expected.to compile.and_raise_error(%r{You require a username (bareos::repository_username) and password (bareos::repository_password) for Bareos subscription repos.}) + } + end + + host = if _params['repository_host'] != :undef + _params['repository_host'] + else + 'download.bareos.com' + end + else + host = if _params['repository_host'] != :undef + _params['repository_host'] + else + 'download.bareos.org' + end + end + + address = "#{schema}://#{host}/bareos/release/#{_params['repository_release']}" + + key_id = case _params['repository_release'] + when '18.2', '19.2' + if _params['repository_subscription'] + '641A1497F1B11BEA945F840FE5D882B28657AE28' + else + 'A0CFE15F71F798574AB363DD118283D9A7862CEE' + end + when '20' + 'C68B001F74D2F20243D0B7A20CCBA537DBE083A6' + when '21' + '91DA1DC3564AE20A76C4CA88E01957D6C9FED482' + end + + it { + is_expected.to contain_class('bareos::repository') + } + + case _facts[:os]['family'] + when 'Debian' + include_examples 'repository::apt', _params, _facts, address, key_id + when 'RedHat' + include_examples 'repository::yum', _params, _facts, address + end +end diff --git a/spec/shared_examples/repository/apt.rb b/spec/shared_examples/repository/apt.rb new file mode 100644 index 0000000..a780387 --- /dev/null +++ b/spec/shared_examples/repository/apt.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: trued +shared_examples 'repository::apt' do |_params, _facts, _address, _key_id| + it { + is_expected.to contain_class('apt') + } + + address = _address + key_id = _key_id + + if _params['repository_subscription'] + it { + is_expected.to contain_file('/etc/apt/auth.conf.d/bareos').with( + { + 'ensure' => 'present', + 'owner' => 'root', + 'group' => 'root', + 'mode' => '0600', + } + ).that_notifies('Class[apt::update]') + } + else + it { + is_expected.to contain_file('/etc/apt/auth.conf.d/bareos').with( + { + 'ensure' => 'absent', + } + ).that_notifies('Class[apt::update]') + } + end + + location = case _facts[:os]['name'] + when 'Debian' + case _facts[:os]['release']['major'] + when '10' + "#{address}/Debian_#{_facts[:os]['release']['major']}" + else + "#{address}/Debian_#{_facts[:os]['release']['major']}.0" + end + when 'Ubuntu' + "#{address}/xUbuntu_#{_facts[:os]['release']['major']}.0" + end + + key = { + 'id' => key_id, + 'source' => "#{address}/Release.key", + }.merge(_params['repository_key']) + + it { + is_expected.to contain_class('bareos::repository::apt') + } + + it { + is_expected.to contain_apt__source('bareos').with( + 'location' => "#{location}", + 'release' => '/', + 'repos' => '', + 'key' => key, + ).that_notifies('Class[apt::update]') + } +end diff --git a/spec/shared_examples/repository/yum.rb b/spec/shared_examples/repository/yum.rb new file mode 100644 index 0000000..0a9d784 --- /dev/null +++ b/spec/shared_examples/repository/yum.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: trued +shared_examples 'repository::yum' do |_params, _facts, _address| + address = _address + + location = case _facts[:os]['name'] + when 'RedHat', 'VirtuozzoLinux' + "#{address}/RHEL_#{_facts[:os]['release']['major']}" + when 'CentOS', 'Rocky', 'AlmaLinux' + if _params['repository_release'] == '21' + "#{address}/EL_#{_facts[:os]['release']['major']}" + else + "#{address}/CentOS_#{_facts[:os]['release']['major']}" + end + when 'Fedora' + "#{address}/Fedora_#{_facts[:os]['release']['major']}" + when 'Amazon' + case _facts[:os]['release']['major'] + when '2' + "#{address}/RHEL_7" + end + end + + yum_username = case _params['repository_username'] + when :undef + 'absent' + else + _params['repository_username'] + end + + yum_password = case _params['repository_password'] + when :undef + 'absent' + else + _params['repository_password'] + end + + it { + is_expected.to contain_class('bareos::repository::yum') + } + + it { + is_expected.to contain_yumrepo('bareos').with( + { + 'descr' => 'Bareos Repository', + 'username' => yum_username, + 'password' => yum_password, + 'baseurl' => location, + 'gpgcheck' => '1', + 'gpgkey' => "#{location}/repodata/repomd.xml.key", + 'priority' => '1', + } + ) + } +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 340a599..4d617f3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -15,5 +15,3 @@ add_custom_fact name.to_sym, value end end - -require_relative './settings_helper' diff --git a/templates/client/director.conf.epp b/templates/client/director.conf.epp new file mode 100644 index 0000000..b2c67f5 --- /dev/null +++ b/templates/client/director.conf.epp @@ -0,0 +1,29 @@ +<%- | Hash $config | -%> + +# This file is managed by puppet +Director { +<% if $config.has_key('address') { %> Address = <%= $config['address'] %><% } %> +<% if $config.has_key('allowed_job_command') { %> Allowed Job Command = <%= $config['allowed_job_command'] %><% } %> +<% if $config.has_key('allowed_script_dir') { %> Allowed Script Dir = <%= $config['allowed_script_dir'] %><% } %> +<% if $config.has_key('connection_from_client_to_director') { %> Connection From Client To Director = <%= $config['connection_from_client_to_director'] %><% } %> +<% if $config.has_key('connection_from_director_to_client') { %> Connection From Director To Client = <%= $config['connection_from_director_to_client'] %><% } %> +<% if $config.has_key('description') { %> Description = <%= $config['description'] %><% } %> +<% if $config.has_key('maximum_bandwidth_per_job') { %> Maximum Bandwidth Per Job = <%= $config['maximum_bandwidth_per_job'] %><% } %> +<% if $config.has_key('monitor') { %> Monitor = <%= $config['monitor'] %><% } %> +<% if $config.has_key('name') { %> Name = <%= $config['name'] %><% } %> +<% if $config.has_key('password') { %> Password = <%= $config['password'] %><% } %> +<% if $config.has_key('port') { %> Port = <%= $config['port'] %><% } %> +<% if $config.has_key('tls_allowed_cn') { %> TLS Allowed CN = <%= $config['tls_allowed_cn'] %><% } %> +<% if $config.has_key('tls_authenticate') { %> TLS Authenticate = <%= $config['tls_authenticate'] %><% } %> +<% if $config.has_key('tls_ca_certificate_dir') { %> TLS CA Certificate Dir = <%= $config['tls_ca_certificate_dir'] %><% } %> +<% if $config.has_key('tls_ca_certificate_file') { %> TLS CA Certificate File = <%= $config['tls_ca_certificate_file'] %><% } %> +<% if $config.has_key('tls_certificate_revocation_list') { %> TLS Certificate = <%= $config['tls_certificate_revocation_list'] %><% } %> +<% if $config.has_key('tls_certificate') { %> TLS Certificate Revocation List = <%= $config['tls_certificate'] %><% } %> +<% if $config.has_key('tls_cipher_list') { %> TLS Cipher List = <%= $config['tls_cipher_list'] %><% } %> +<% if $config.has_key('tls_dh_file') { %> TLS DH File = <%= $config['tls_dh_file'] %><% } %> +<% if $config.has_key('tls_enable') { %> TLS Enable = <%= $config['tls_enable'] %><% } %> +<% if $config.has_key('tls_key') { %> TLS Key = <%= $config['tls_key'] %><% } %> +<% if $config.has_key('tls_protocal') { %> TLS Protocol = <%= $config['tls_protocal'] %><% } %> +<% if $config.has_key('tls_require') { %> TLS Require = <%= $config['tls_require'] %><% } %> +<% if $config.has_key('tls_verify_peer') { %> TLS Verify Peer = <%= $config['tls_verify_peer'] %><% } %> +} diff --git a/templates/client/fd.conf.epp b/templates/client/fd.conf.epp new file mode 100644 index 0000000..a4cd74b --- /dev/null +++ b/templates/client/fd.conf.epp @@ -0,0 +1,52 @@ +<%- | Hash $config | -%> + +# This file is managed by puppet +Client { +<% if $config.has_key('absolute_job_timeout') { %> Absolute Job Timeout = <%= $config['absolute_job_timeout'] %><% } %> +<% if $config.has_key('allow_bandwidth_bursting') { %> Allow Bandwidth Bursting = <%= $config['allow_bandwidth_bursting'] %><% } %> +<% if $config.has_key('allowed_job_command') { %> Allowed Job Command = <%= $config['allowed_job_command'] %><% } %> +<% if $config.has_key('allowed_script_dir') { %> Allowed Script Dir = <%= $config['allowed_script_dir'] %><% } %> +<% if $config.has_key('always_use_lmdb') { %> Always Use LMDB = <%= $config['always_use_lmdb'] %><% } %> +<% if $config.has_key('compatible') { %> Compatible = <%= $config['compatible'] %><% } %> +<% if $config.has_key('description') { %> Description = <%= $config['description'] %><% } %> +<% if $config.has_key('fd_address') { %> FD Address = <%= $config['fd_address'] %><% } %> +<% if $config.has_key('fd_addresses') { %> FD Addresses = <%= $config['fd_addresses'] %><% } %> +<% if $config.has_key('fd_port') { %> FD Port = <%= $config['fd_port'] %><% } %> +<% if $config.has_key('fd_source_address') { %> FD Source Address = <%= $config['fd_source_address'] %><% } %> +<% if $config.has_key('heartbeat_interval') { %> Heartbeat Interval = <%= $config['heartbeat_interval'] %><% } %> +<% if $config.has_key('lmdb_threshold') { %> LMDB Threshold = <%= $config['lmdb_threshold'] %><% } %> +<% if $config.has_key('log_timestamp_format') { %> Log Timestamp Format = <%= $config['log_timestamp_format'] %><% } %> +<% if $config.has_key('maximum_bandwidth_per_job') { %> Maximum Bandwidth Per Job = <%= $config['maximum_bandwidth_per_job'] %><% } %> +<% if $config.has_key('maximum_concurrent_jobs') { %> Maximum Concurrent Jobs = <%= $config['maximum_concurrent_jobs'] %><% } %> +<% if $config.has_key('maximum_connections') { %> Maximum Connections = <%= $config['maximum_connections'] %><% } %> +<% if $config.has_key('maximum_network_buffer_size') { %> Maximum Network Buffer Size = <%= $config['maximum_network_buffer_size'] %><% } %> +<% if $config.has_key('messages') { %> Messages = <%= $config['messages'] %><% } %> +<% if $config.has_key('client_name') { %> Name = <%= $config['client_name'] %><% } %> +<% if $config.has_key('pid_directory') { %> Pid Directory = <%= $config['pid_directory'] %><% } %> +<% if $config.has_key('pki_cipher') { %> Pki Cipher = <%= $config['pki_cipher'] %><% } %> +<% if $config.has_key('pki_encryption') { %> Pki Encryption = <%= $config['pki_encryption'] %><% } %> +<% if $config.has_key('pki_key_pair') { %> Pki Key Pair = <%= $config['pki_key_pair'] %><% } %> +<% if $config.has_key('pki_master_key') { %> Pki Master Key = <%= $config['pki_master_key'] %><% } %> +<% if $config.has_key('pki_signatures') { %> Pki Signatures = <%= $config['pki_signatures'] %><% } %> +<% if $config.has_key('pki_signer') { %> Pki Signer = <%= $config['pki_signer'] %><% } %> +<% if $config.has_key('plugin_directory') { %> Plugin Directory = <%= $config[''] %><% } %> +<% if $config.has_key('plugin_names') { %> Plugin Names = <%= $config[''] %><% } %> +<% if $config.has_key('scripts_directory') { %> Scripts Directory = <%= $config[''] %><% } %> +<% if $config.has_key('sd_connect_timeout') { %> SD Connect Timeout = <%= $config[''] %><% } %> +<% if $config.has_key('secure_erase_command') { %> Secure Erase Command = <%= $config[''] %><% } %> +<% if $config.has_key('tls_allowed_cn') { %> TLS Allowed CN = <%= $config['tls_allowed_cn'] %><% } %> +<% if $config.has_key('tls_authenticate') { %> TLS Authenticate = <%= $config['tls_authenticate'] %><% } %> +<% if $config.has_key('tls_ca_certificate_dir') { %> TLS CA Certificate Dir = <%= $config['tls_ca_certificate_dir'] %><% } %> +<% if $config.has_key('tls_ca_certificate_file') { %> TLS CA Certificate File = <%= $config['tls_ca_certificate_file'] %><% } %> +<% if $config.has_key('tls_certificate') { %> TLS Certificate = <%= $config['tls_certificate'] %><% } %> +<% if $config.has_key('tls_certificate_revocation_list') { %> TLS Certificate Revocation List = <%= $config['tls_certificate_revocation_list'] %><% } %> +<% if $config.has_key('tls_cipher_list') { %> TLS Cipher List = <%= $config['tls_cipher_list'] %><% } %> +<% if $config.has_key('tls_dh_file') { %> TLS DH File = <%= $config['tls_dh_file'] %><% } %> +<% if $config.has_key('tls_enable') { %> TLS Enable = <%= $config['tls_enable'] %><% } %> +<% if $config.has_key('tls_key') { %> TLS Key = <%= $config['tls_key'] %><% } %> +<% if $config.has_key('tls_protocal') { %> TLS Protocol = <%= $config['tls_protocal'] %><% } %> +<% if $config.has_key('tls_require') { %> TLS Require = <%= $config['tls_require'] %><% } %> +<% if $config.has_key('tls_verify_peer') { %> TLS Verify Peer = <%= $config['tls_verify_peer'] %><% } %> +<% if $config.has_key('ver_id') { %> Ver Id = <%= $config['ver_id'] %><% } %> +<% if $config.has_key('working_directory') { %> Working Directory = <%= $config['working_directory'] %><% } %> +} diff --git a/templates/webui_configuration.erb b/templates/webui/webui_configuration.epp similarity index 50% rename from templates/webui_configuration.erb rename to templates/webui/webui_configuration.epp index 1d31515..97e062b 100644 --- a/templates/webui_configuration.erb +++ b/templates/webui/webui_configuration.epp @@ -1,23 +1,31 @@ +<%- | $session_timeout, + $pagination_values, + $pagination_default_value, + $save_previous_state, + $label_pooltype, +| -%> + + # This file is managed by puppet [session] # Default: 3600 seconds -timeout=<%= @session_timeout %> +timeout=<%= $session_timeout %> [tables] # Possible values for pagination # Default: 10,25,50,100 -pagination_values=<%= @pagination_values %> +pagination_values=<%= $pagination_values %> # Default number of rows per page # for possible values see pagination_values # Default: 25 -pagination_default_value=<%= @pagination_default_value %> +pagination_default_value=<%= $pagination_default_value %> # State saving - restore table state on page reload. # Default: false -save_previous_state=<%= @save_previous_state %> +save_previous_state=<%= $save_previous_state %> [autochanger] # Pooltype for label to use as filter. # Default: none -labelpooltype=<%= @label_pooltype %> +labelpooltype=<%= $label_pooltype %> diff --git a/templates/webui_directors.erb b/templates/webui/webui_directors.epp similarity index 60% rename from templates/webui_directors.erb rename to templates/webui/webui_directors.epp index c97b9a5..311e62c 100644 --- a/templates/webui_directors.erb +++ b/templates/webui/webui_directors.epp @@ -1,19 +1,19 @@ -[<%= @name %>] +[<%= $titel %>] ; Enable or disable section. Possible values are "yes" or "no", the default is "yes". -enabled = "<%= @enabled %>" +enabled = "<%= $enabled %>" ; Fill in the IP-Address or FQDN of you director. -diraddress = "<%= @dir_address %>" +diraddress = "<%= $director_address %>" ; Default value is 9101 -dirport = <%= @dir_port %> -<%- if @catalog -%> +dirport = <%= $director_port %> +<%- if $catalog -%> ; Set catalog to explicit value if you have multiple catalogs -catalog = "<%= @catalog %>" +catalog = "<%= $catalog %>" <%- end -%> -<%-if @pam_console_name -%> -pam_console_name = "<%= @pam_console_name %>" +<%-if $pam_console_name -%> +pam_console_name = "<%= $pam_console_name %>" <%- end -%> -<%-if @pam_console_password -%> -pam_console_password = "<%= @pam_console_password %>" +<%-if $pam_console_password -%> +pam_console_password = "<%= $pam_console_password %>" <%- end -%> ; Note: TLS has not been tested and documented, yet. ;tls_verify_peer = false diff --git a/types/acl.pp b/types/acl.pp new file mode 100644 index 0000000..71c6827 --- /dev/null +++ b/types/acl.pp @@ -0,0 +1,8 @@ +# @summary Bareos +# +# @see https://docs.bareos.org/Configuration/CustomizingTheConfiguration.html#datatype-acl +# +type Bareos::Acl = Variant[ + String[1], + Array[String[1]], +] diff --git a/types/actiononpurge.pp b/types/actiononpurge.pp new file mode 100644 index 0000000..c989cb8 --- /dev/null +++ b/types/actiononpurge.pp @@ -0,0 +1,7 @@ +# @summary Bareos +# +# @see https://docs.bareos.org/Configuration/CustomizingTheConfiguration.html#datatype-action_on_purge +# +type Bareos::ActionOnPurge = Enum[ + 'truncate', +] diff --git a/types/address.pp b/types/address.pp new file mode 100644 index 0000000..3e0b6cf --- /dev/null +++ b/types/address.pp @@ -0,0 +1,7 @@ +# @summary Bareos +# +# @see https://docs.bareos.org/Configuration/CustomizingTheConfiguration.html#datatype-address +# +type Bareos::Address = Variant[ + Stdlib::Host, +] diff --git a/types/addresses.pp b/types/addresses.pp new file mode 100644 index 0000000..a4ba2bf --- /dev/null +++ b/types/addresses.pp @@ -0,0 +1,33 @@ +# @summary Bareos +# +# @see https://docs.bareos.org/Configuration/CustomizingTheConfiguration.html#datatype-addresses +# +type Bareos::Addresses = Hash[ + Optional[ + Hash[ + Enum['ip'], + Struct[ + addr => Stdlib::Host, + port => Stdlib::Port, + ], + ] + ], + Optional[ + Hash[ + Enum['ip4'], + Struct[ + addr => Variant[Stdlib::Fdqn, Stdlib::IP::Address::V4], + port => Stdlib::Port, + ], + ] + ], + Optional[ + Hash[ + Enum['ip6'], + Struct[ + addr => Variant[Stdlib::Fdqn, Stdlib::IP::Address::V6], + port => Stdlib::Port, + ], + ] + ], +] diff --git a/types/auditcommandlist.pp b/types/auditcommandlist.pp new file mode 100644 index 0000000..d8c9236 --- /dev/null +++ b/types/auditcommandlist.pp @@ -0,0 +1,16 @@ +# @summary Bareos +# +# @see https://docs.bareos.org/Configuration/CustomizingTheConfiguration.html#datatype-audit_command_list +# +type Bareos::AuditCommandList = Variant[ + Enum[ + 'label', + 'restore', + ], + Array[ + Enum[ + 'label', + 'restore', + ] + ], +] diff --git a/types/authprotocaltype.pp b/types/authprotocaltype.pp new file mode 100644 index 0000000..e734b74 --- /dev/null +++ b/types/authprotocaltype.pp @@ -0,0 +1,10 @@ +# @summary Bareos +# +# @see https://docs.bareos.org/Configuration/CustomizingTheConfiguration.html#datatype-auth_protocol_type +# +type Bareos::AuthProtocolType = Enum[ + 'Native', + 'NDMPV2', + 'NDMPV3', + 'NDMPV4', +] diff --git a/types/authtype.pp b/types/authtype.pp new file mode 100644 index 0000000..fac33bf --- /dev/null +++ b/types/authtype.pp @@ -0,0 +1,9 @@ +# @summary Bareos +# +# @see https://docs.bareos.org/Configuration/CustomizingTheConfiguration.html#datatype-auth_type +# +type Bareos::AuthType = Enum[ + 'None', + 'Clear', + 'MD5', +] diff --git a/types/autopassword.pp b/types/autopassword.pp new file mode 100644 index 0000000..065139c --- /dev/null +++ b/types/autopassword.pp @@ -0,0 +1,5 @@ +# @summary Bareos +# +# @see https://docs.bareos.org/Configuration/CustomizingTheConfiguration.html#datatype-autopassword +# +type Bareos::AutoPassword = String diff --git a/types/backuplevel.pp b/types/backuplevel.pp new file mode 100644 index 0000000..59c4aa7 --- /dev/null +++ b/types/backuplevel.pp @@ -0,0 +1,14 @@ +# @summary Bareos +# +# @see https://docs.bareos.org/Configuration/CustomizingTheConfiguration.html#datatype-backup_level +# +type Bareos::BackupLevel = Enum[ + 'Full', + 'Differential', + 'Incremental', + 'VirtualFull', + 'InitCatalog', + 'Catalog', + 'VolumeToCatalog', + 'DiskToCatalog', +] diff --git a/types/bit.pp b/types/bit.pp new file mode 100644 index 0000000..7897e58 --- /dev/null +++ b/types/bit.pp @@ -0,0 +1,5 @@ +# @summary Bareos +# +# @see https://docs.bareos.org/Configuration/CustomizingTheConfiguration.html#datatype-bit +# +type Bareos::Bit = Bareos::Boolean diff --git a/types/boolean.pp b/types/boolean.pp index 4a77be5..aff0e85 100644 --- a/types/boolean.pp +++ b/types/boolean.pp @@ -1,2 +1,11 @@ -# @summary Bareos boolean datatype -type Bareos::Boolean = Variant[Boolean, Enum['yes', 'no']] +# @summary Bareos +# +# @see https://docs.bareos.org/Configuration/CustomizingTheConfiguration.html#datatype-boolean +# +type Bareos::Boolean = Variant[ + Boolean, + Enum[ + 'yes', + 'no', + ], +] diff --git a/types/client/config.pp b/types/client/config.pp new file mode 100644 index 0000000..28f99ea --- /dev/null +++ b/types/client/config.pp @@ -0,0 +1,4 @@ +# @summary Bareos boolean datatype +type Bareos::Client::Config = Hash[ + +] diff --git a/types/client/config/fd.pp b/types/client/config/fd.pp new file mode 100644 index 0000000..5691f98 --- /dev/null +++ b/types/client/config/fd.pp @@ -0,0 +1,55 @@ +# @summary Bareos boolean datatype +type Bareos::Client::Config:Fd = Hash[ + Enum['fd'], + Struct[ + { + absolute_job_timeout => Optional[Integer], + allow_bandwidth_bursting => Optional[Boolean], + allowed_job_command => Optional[String], + allowed_script_dir => + always_use_lmdb => + compatible => + description => + fd_address => + fd_addresses => + fd_port => + fd_source_address => + heartbeat_interval => + lmdb_threshold => + log_timestamp_format => + maximum_bandwidth_per_job => + maximum_concurrent_jobs => + maximum_connections => + maximum_network_buffer_size => + messages => + client_name => + pid_directory => + pki_cipher => + pki_encryption => + pki_key_pair => + pki_master_key => + pki_signatures => + pki_signer => + plugin_directory => + plugin_names => + scripts_directory => + sd_connect_timeout => + secure_erase_command => + tls_allowed_cn => + tls_authenticate => + tls_ca_certificate_dir => + tls_ca_certificate_file => + tls_certificate => + tls_certificate_revocation_list => + tls_cipher_list => + tls_dh_file => + tls_enable => + tls_key => + tls_protocal => + tls_require => + tls_verify_peer => + ver_id => + working_directory => + } + ] +] diff --git a/types/compressionalgorithm.pp b/types/compressionalgorithm.pp new file mode 100644 index 0000000..78b50b0 --- /dev/null +++ b/types/compressionalgorithm.pp @@ -0,0 +1,13 @@ +# @summary Bareos +# +# @see https://docs.bareos.org/Configuration/CustomizingTheConfiguration.html#datatype-compression_algorithm +# +type Bareos::CompressionAlgorithm = Variant[ + Pattern[/GZIP[1-9]/], + Enum[ + 'LZO', + 'LZFAST', + 'LZ4', + 'LZ4HC', + ] +] diff --git a/types/device.pp b/types/device.pp new file mode 100644 index 0000000..6b866c1 --- /dev/null +++ b/types/device.pp @@ -0,0 +1,5 @@ +# @summary Bareos +# +# @see https://docs.bareos.org/Configuration/CustomizingTheConfiguration.html#datatype-device +# +type Bareos::Device = String diff --git a/types/devicetype.pp b/types/devicetype.pp new file mode 100644 index 0000000..1e6d00b --- /dev/null +++ b/types/devicetype.pp @@ -0,0 +1,12 @@ +# @summary Bareos +# +# @see https://docs.bareos.org/Configuration/CustomizingTheConfiguration.html#datatype-device_type +# +type Bareos::DeviceType = Enum[ + 'Tape', + 'File', + 'FIFO', + 'GFAPI', + 'Rados', + 'Droplet', +] diff --git a/types/directory.pp b/types/directory.pp new file mode 100644 index 0000000..e2d46e8 --- /dev/null +++ b/types/directory.pp @@ -0,0 +1,5 @@ +# @summary Bareos +# +# @see https://docs.bareos.org/Configuration/CustomizingTheConfiguration.html#datatype-directory +# +type Bareos::Directory = Stdlib::Absolutepath diff --git a/types/directorylist.pp b/types/directorylist.pp new file mode 100644 index 0000000..0d74b4c --- /dev/null +++ b/types/directorylist.pp @@ -0,0 +1,7 @@ +# @summary Bareos +# +# @see https://docs.bareos.org/Configuration/CustomizingTheConfiguration.html#datatype-directory_list +# +type Bareos::DirectoryList = Array[ + Stdlib::Absolutepath +] diff --git a/types/include.pp b/types/include.pp new file mode 100644 index 0000000..d820b7f --- /dev/null +++ b/types/include.pp @@ -0,0 +1,5 @@ +# @summary Bareos +# +# @see https://docs.bareos.org/Configuration/CustomizingTheConfiguration.html#datatype-directory_list +# +type Bareos::Include = Hash diff --git a/types/list.pp b/types/list.pp deleted file mode 100644 index 8ba4808..0000000 --- a/types/list.pp +++ /dev/null @@ -1,2 +0,0 @@ -# @summary Bareos List data type -type Bareos::List = Variant[String, Array[String]] diff --git a/types/repository/key.pp b/types/repository/key.pp new file mode 100644 index 0000000..9243469 --- /dev/null +++ b/types/repository/key.pp @@ -0,0 +1,6 @@ +# @summary Bareos List data type +# +type Bareos::Repository::Key = Hash[ + id => Optional[String[1]], + source => Optional[Stdlib::HTTPUrl], +] diff --git a/types/resource.pp b/types/resource.pp deleted file mode 100644 index bb8f57a..0000000 --- a/types/resource.pp +++ /dev/null @@ -1,2 +0,0 @@ -# @summary Bareos Resource data type -type Bareos::Resource = Pattern[/(?i:^[a-z][a-z0-9\.\-_ \$]{0,126}$)/] diff --git a/types/version.pp b/types/version.pp new file mode 100644 index 0000000..ec85cd8 --- /dev/null +++ b/types/version.pp @@ -0,0 +1,8 @@ +# @summary Bareos List data type +# +type Bareos::Version = Enum[ + '18.2', + '19.2', + '20', + '21', +]