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' 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/examples/init.pp b/examples/init.pp index a5f3395..ba021f8 100644 --- a/examples/init.pp +++ b/examples/init.pp @@ -1,23 +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 -# -class { 'bareos': - manage_repo => false, +include postgresql::server +$storage_password = 'Password of the storage instance' + +postgresql::server::db { 'bareos_catalog': + user => 'dbuser', + password => postgresql::postgresql_password('bareos_catalog', 'dbpass'), } -class { 'bareos::director::director': - password => 'pw', +# 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', } -class { 'bareos::storage::storage': + +# add the client to the config +bareos::director::client { 'bareos-client': + description => 'Your fancy client to backup', + password => 'MyClientPasswordPleaseChange', + address => 'localhost', +} + +# 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 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 02ed04c..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,8 +56,10 @@ } } - file { $config_dir: + file { [$config_dir, $export_dir]: ensure => directory, + purge => true, + recurse => true, force => true, mode => $bareos::file_dir_mode, owner => $bareos::file_owner, @@ -83,6 +86,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/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, diff --git a/manifests/init.pp b/manifests/init.pp index f253333..45f6c0b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -102,10 +102,12 @@ ensure => directory, purge => true, recurse => true, + force => true, recurselimit => 1, mode => $bareos::file_dir_mode, owner => $bareos::file_owner, group => $bareos::file_group, + require => Package[$package_name], tag => ['bareos', 'bareos_core'], } } 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', 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 } 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