From d3e86cfa26894f511d704a634996d1123496bd24 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Thu, 3 Nov 2022 15:24:11 -0700 Subject: [PATCH 01/10] set 'postgresql' as only valid director::catalog::db_driver param value As of bareos 21, the only supported db is `postgres` and the `DB Driver` configuration directive itself is deprecated. The puppet parameter is being left in place "for the moment" to catch existing users of this module which may have been setting a different DB backend via hiera. See: https://docs.bareos.org/Configuration/Director.html#config-Dir_Catalog_DbDriver --- manifests/director/catalog.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/director/catalog.pp b/manifests/director/catalog.pp index d6fb8f0..b8ab3ae 100644 --- a/manifests/director/catalog.pp +++ b/manifests/director/catalog.pp @@ -134,7 +134,7 @@ define bareos::director::catalog ( $ensure = present, $db_address = undef, - $db_driver = undef, + Enum['postgresql'] $db_driver = 'postgresql', $db_name = undef, $db_password = undef, $db_port = undef, From e09154381bed7e70ee9b0559df5bb0567465cb56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Mon, 14 Mar 2022 07:32:03 -1000 Subject: [PATCH 02/10] Update with ModuleSync --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49981e3..8a07791 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,4 +13,6 @@ concurrency: jobs: puppet: name: Puppet - uses: voxpupuli/gha-puppet/.github/workflows/basic.yml@v1 + uses: voxpupuli/gha-puppet/.github/workflows/beaker.yml@v1 + with: + pidfile_workaround: 'false' From bbb3a8883360cf07addab0285388d5bc003d5316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Mon, 14 Mar 2022 07:32:32 -1000 Subject: [PATCH 03/10] Add acceptance testing --- .sync.yml | 2 ++ spec/acceptance/bareos_spec.rb | 7 +++++++ spec/spec_helper_acceptance.rb | 10 ++++++++++ 3 files changed, 19 insertions(+) create mode 100644 spec/acceptance/bareos_spec.rb create mode 100644 spec/spec_helper_acceptance.rb diff --git a/.sync.yml b/.sync.yml index 0fc6d65..6dfefcd 100644 --- a/.sync.yml +++ b/.sync.yml @@ -1,3 +1,5 @@ --- spec/spec_helper.rb: spec_overrides: "require_relative './settings_helper'" +spec/spec_helper_acceptance.rb: + unmanaged: false diff --git a/spec/acceptance/bareos_spec.rb b/spec/acceptance/bareos_spec.rb new file mode 100644 index 0000000..0308816 --- /dev/null +++ b/spec/acceptance/bareos_spec.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require 'spec_helper_acceptance' + +describe 'bareos class' do + it_behaves_like 'the example', 'init.pp' +end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb new file mode 100644 index 0000000..d3a6e23 --- /dev/null +++ b/spec/spec_helper_acceptance.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +require 'voxpupuli/acceptance/spec_helper_acceptance' + +configure_beaker + +Dir['./spec/support/acceptance/**/*.rb'].sort.each { |f| require f } From c37970e741f1d6b04440194054d406b7d02e9c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Mon, 14 Mar 2022 07:52:06 -1000 Subject: [PATCH 04/10] Use module default parameters --- examples/init.pp | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/init.pp b/examples/init.pp index a5f3395..7b4fd05 100644 --- a/examples/init.pp +++ b/examples/init.pp @@ -10,7 +10,6 @@ # https://docs.puppet.com/guides/tests_smoke.html # class { 'bareos': - manage_repo => false, } class { 'bareos::director::director': password => 'pw', From 50d0348367c69b7ecdc1557f8a47721c3c3cfc62 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Thu, 3 Nov 2022 10:12:13 -0700 Subject: [PATCH 05/10] (WIP) add postgresql db to acceptance test --- examples/init.pp | 21 +++++++++++++++++++-- manifests/director.pp | 1 + spec/support/acceptance/setup.rb | 5 +++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 spec/support/acceptance/setup.rb diff --git a/examples/init.pp b/examples/init.pp index 7b4fd05..77f7b28 100644 --- a/examples/init.pp +++ b/examples/init.pp @@ -9,11 +9,28 @@ # Learn more about module testing here: # https://docs.puppet.com/guides/tests_smoke.html # -class { 'bareos': -} + +include postgresql::server + +class { 'bareos': } + class { 'bareos::director::director': password => 'pw', } + +postgresql::server::db { 'bareos_catalog': + user => 'dbuser', + password => postgresql::postgresql_password('bareos', 'dbpass'), +} +-> bareos::director::catalog { 'bareos_catalog': + db_driver => 'postgresql', + db_name => 'bareos_catalog', + db_address => '127.0.0.1', + db_port => 5432, + db_user => 'dbuser', + db_password => 'dbpass', +} + class { 'bareos::client::client': } class { 'bareos::storage::storage': diff --git a/manifests/director.pp b/manifests/director.pp index 02ed04c..92e301f 100644 --- a/manifests/director.pp +++ b/manifests/director.pp @@ -83,6 +83,7 @@ if $manage_database { File <| tag == 'bareos_director' |> -> exec { 'bareos director init catalog': + user => 'postgres', command => '/usr/lib/bareos/scripts/create_bareos_database && /usr/lib/bareos/scripts/make_bareos_tables && /usr/lib/bareos/scripts/grant_bareos_privileges', notify => Service[$bareos::director::service_name], refreshonly => true, diff --git a/spec/support/acceptance/setup.rb b/spec/support/acceptance/setup.rb new file mode 100644 index 0000000..8bd8bcc --- /dev/null +++ b/spec/support/acceptance/setup.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +configure_beaker do |host| + install_module_from_forge_on(host, 'puppetlabs/postgresql', '> 8 < 9') +end From 1529c53001150947c322825a5b3a11a2e5eab48a Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Fri, 4 Nov 2022 12:17:12 -0700 Subject: [PATCH 06/10] fix bareos package/file purge ordering --- manifests/init.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/init.pp b/manifests/init.pp index f253333..22b3c35 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -106,6 +106,7 @@ mode => $bareos::file_dir_mode, owner => $bareos::file_owner, group => $bareos::file_group, + require => Package[$package_name], tag => ['bareos', 'bareos_core'], } } From 14751b3a5ffdc4d88dafa507a9270ac5a14d9db5 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Fri, 4 Nov 2022 12:33:55 -0700 Subject: [PATCH 07/10] fix recursive directory purging Resolves these warnings: Notice: /Stage[main]/Bareos/File[/etc/bareos/bareos-dir-export]: Not removing directory; use 'force' to override --- manifests/director.pp | 2 ++ manifests/init.pp | 1 + 2 files changed, 3 insertions(+) diff --git a/manifests/director.pp b/manifests/director.pp index 92e301f..ceb993e 100644 --- a/manifests/director.pp +++ b/manifests/director.pp @@ -57,6 +57,8 @@ file { $config_dir: ensure => directory, + purge => true, + recurse => true, force => true, mode => $bareos::file_dir_mode, owner => $bareos::file_owner, diff --git a/manifests/init.pp b/manifests/init.pp index 22b3c35..45f6c0b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -102,6 +102,7 @@ ensure => directory, purge => true, recurse => true, + force => true, recurselimit => 1, mode => $bareos::file_dir_mode, owner => $bareos::file_owner, From 66281653e717344caacdccc8a08292a4bb13b100 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Fri, 4 Nov 2022 12:38:03 -0700 Subject: [PATCH 08/10] fix array formatting --- manifests/params.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index 84386cd..ebef52b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -24,7 +24,8 @@ 'bareos-database-tools', ] $director_service_name = 'bareos-dir' - $director_managed_dirs = ['catalog', + $director_managed_dirs = [ + 'catalog', 'client', 'console', 'counter', From bd9abae095c795ed171f3e94832463e515a87df5 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Fri, 4 Nov 2022 14:33:57 -0700 Subject: [PATCH 09/10] fix bconsole.conf package/file purge ordering --- manifests/console.pp | 6 ++++++ manifests/director.pp | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/manifests/console.pp b/manifests/console.pp index d5507fa..81f41f7 100644 --- a/manifests/console.pp +++ b/manifests/console.pp @@ -35,4 +35,10 @@ require => Package[$package_name], tag => ['bareos', 'bareos_console'], } + + file { "${bareos::config_dir}/bconsole.conf": + ensure => absent, + force => true, + require => Package[$package_name], + } } diff --git a/manifests/director.pp b/manifests/director.pp index ceb993e..8bb7a2a 100644 --- a/manifests/director.pp +++ b/manifests/director.pp @@ -15,6 +15,7 @@ $service_ensure = $bareos::service_ensure, $service_enable = $bareos::service_enable, $config_dir = "${bareos::config_dir}/bareos-dir.d", + $export_dir = "${bareos::config_dir}/bareos-dir-export", Array[String] $managed_dirs = $bareos::director_managed_dirs, Hash $catalogs = {}, Hash $clients = {}, @@ -55,7 +56,7 @@ } } - file { $config_dir: + file { [$config_dir, $export_dir]: ensure => directory, purge => true, recurse => true, From c6f4bce712cbd5516b5c568697b623ceb2927144 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Fri, 4 Nov 2022 14:46:44 -0700 Subject: [PATCH 10/10] (WIP) testing README example --- examples/init.pp | 63 +++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/examples/init.pp b/examples/init.pp index 77f7b28..ba021f8 100644 --- a/examples/init.pp +++ b/examples/init.pp @@ -1,39 +1,42 @@ -# The baseline for module testing used by Puppet Labs is that each manifest -# should have a corresponding test manifest that declares that class or defined -# type. -# -# Tests are then run by using puppet apply --noop (to check for compilation -# errors and view a log of events) or by fully applying the test in a virtual -# environment (to compare the resulting system state to the desired state). -# -# Learn more about module testing here: -# https://docs.puppet.com/guides/tests_smoke.html -# - include postgresql::server - -class { 'bareos': } - -class { 'bareos::director::director': - password => 'pw', -} +$storage_password = 'Password of the storage instance' postgresql::server::db { 'bareos_catalog': user => 'dbuser', - password => postgresql::postgresql_password('bareos', 'dbpass'), + password => postgresql::postgresql_password('bareos_catalog', 'dbpass'), } --> bareos::director::catalog { 'bareos_catalog': - db_driver => 'postgresql', - db_name => 'bareos_catalog', - db_address => '127.0.0.1', - db_port => 5432, - db_user => 'dbuser', - db_password => 'dbpass', +# Install and configure an Director Server +-> class { 'bareos::profile::director': + password => 'Password of the director instance itself', + storage_address => 'localhost', + storage_password => $storage_password, + catalog_conf => { + 'db_name' => 'bareos_catalog', + 'db_address' => '127.0.0.1', + 'db_port' => 5432, + 'db_user' => 'dbuser', + 'db_password' => 'dbpass', + }, } -class { 'bareos::client::client': +include bareos::profile::director::fileset +include bareos::profile::director::jobdefs + +# add storage server to the same machine +class { 'bareos::profile::storage': + password => $storage_password, + archive_device => '/var/lib/bareos/storage', +} + +# add the client to the config +bareos::director::client { 'bareos-client': + description => 'Your fancy client to backup', + password => 'MyClientPasswordPleaseChange', + address => 'localhost', } -class { 'bareos::storage::storage': + +# Create an backup job by referencing to the jobDef template. +bareos::director::job { 'backup-bareos-client': + job_defs => 'DefaultJob', + client => 'bareos-client', # which client to assign this job } -include bareos::console -include bareos::monitor