Skip to content

Commit

Permalink
added possibility to config defined types via hiera
Browse files Browse the repository at this point in the history
  • Loading branch information
Benedikt Braunger committed Sep 23, 2020
1 parent d325478 commit e6511fd
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 8 deletions.
47 changes: 39 additions & 8 deletions manifests/storage.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@
# 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::storage(
$manage_service = $::bareos::manage_service,
$manage_package = $::bareos::manage_package,
$package_name = $::bareos::storage_package_name,
$package_ensure = $::bareos::package_ensure,
$service_name = $::bareos::storage_service_name,
$service_ensure = $::bareos::service_ensure,
$service_enable = $::bareos::service_enable,
$config_dir = "${::bareos::config_dir}/bareos-sd.d"
$manage_service = $::bareos::manage_service,
$manage_package = $::bareos::manage_package,
$package_name = $::bareos::storage_package_name,
$package_ensure = $::bareos::package_ensure,
$service_name = $::bareos::storage_service_name,
$service_ensure = $::bareos::service_ensure,
$service_enable = $::bareos::service_enable,
$config_dir = "${::bareos::config_dir}/bareos-sd.d",
Hash $autochangers = {},
Has$devices = {},
Has$directors = {},
Has$messages = {},
Has$ndmps = {},
) inherits ::bareos {
include ::bareos::storage::storage

Expand Down Expand Up @@ -54,4 +59,30 @@
notify => Service[$service_name],
tag => ['bareos', 'bareos_storage'],
}

$autochangers.each |String $resource, Hash $attributes| {
bareos::storage::autochanger { $resource:
* => $attributes;
}
}
$devices.each |String $resource, Hash $attributes| {
bareos::storage::device { $resource:
* => $attributes;
}
}
$directors.each |String $resource, Hash $attributes| {
bareos::storage::director { $resource:
* => $attributes;
}
}
$messages.each |String $resource, Hash $attributes| {
bareos::storage::message { $resource:
* => $attributes;
}
}
$ndmps.each |String $resource, Hash $attributes| {
bareos::storage::ndmp { $resource:
* => $attributes;
}
}
}
94 changes: 94 additions & 0 deletions spec/classes/storage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,98 @@
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" }}}' do
let(:params) do
{
autochangers: {
test: {
changer_command: "foo",
changer_device: "/dev/foo",
device: "dev01",
}
}
}
end
it { is_expected.to compile }
it do
is_expected.to contain_bareos__storage__autochanger('test')
.with_changer_command('foo')
.with_changer_device('/dev/foo')
.with_device('dev01'),
end
end

context 'with devices => { test: { archive_device => "/mnt/test", media_type => "file" }}}' do
let(:params) do
{
devices: {
test: {
archive_device: "/mnt/test",
media_type: "file",
}
}
}
end
it { is_expected.to compile }
it do
is_expected.to contain_bareos__storage__device('test')
.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
is_expected.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
is_expected.to contain_bareos__storage__message('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
is_expected.to contain_bareos__storage__ndmp('test')
.with_username('test'),
.with_password('password'),
end
end

end

0 comments on commit e6511fd

Please sign in to comment.