Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to configure defined types via hiera #54

Merged
merged 9 commits into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ matrix:
env: PUPPET_GEM_VERSION="~> 4.6.0" STRICT_VARIABLES=yes
- rvm: 1.9.3
env: PUPPET_GEM_VERSION="~> 5.0.1" STRICT_VARIABLES=yes
# eclude all puppet 3.x 5.x for ruby 2.3
- rvm: 2.3
env: PUPPET_GEM_VERSION="~> 5.0.1" STRICT_VARIABLES=yes
# eclude all puppet 3.x 4.x for ruby 2.4
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
1. [Monitor (Tray)](#monitor)
1. [Storage](#storage)
1. [Web UI](#webui)
1. [Hiera](#hiera)
1. [Limitations - OS compatibility, etc.](#limitations)

## Description
Expand Down Expand Up @@ -391,6 +392,31 @@ Additional configuration is required on the **Director** server.
}
```

### Hiera
Since define ressource are used in the module they can not be used directly via hiera. Execptions are ofcourse the three classes mentioned in [Reference](#reference).
But there exist hashes for the configuration directives in the `bareos::director` and the `bareos::webui` classes which can be used via hiera.

```
classes:
- bareos::director
bareos::director::director::name_director: 'example'
bareos::director::director::password: 'foobar'
bareos::director::catalogs:
'testing':
db_driver: 'postgresql'
db_name: 'test'
bareos::director::clients:
'alice':
address: foo.bar
password: foobar
bareos::director::jobs:
'backup-alice':
messages: testing
pool: testing
type: backup
client: alice
file_set: testing

## Limitations

This module is built upon and tested against the versions of Puppet listed in the metadata.json file (i.e. the listed compatible versions on the Puppet Forge).
Expand Down
69 changes: 69 additions & 0 deletions manifests/director.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@
$service_enable = $::bareos::service_enable,
$config_dir = "${::bareos::config_dir}/bareos-dir.d",
Array[String] $managed_dirs = $::bareos::director_managed_dirs,
Hash $catalogs = {},
Hash $clients = {},
Hash $consoles = {},
Hash $counters = {},
Hash $directors = {},
Hash $filesets = {},
Hash $jobs = {},
Hash $jobdefs = {},
Hash $messages = {},
Hash $pools = {},
Hash $profiles = {},
Hash $schedules = {},
Hash $storages = {},
) inherits ::bareos {
include ::bareos::director::director

Expand Down Expand Up @@ -67,4 +80,60 @@
tag => ['bareos', 'bareos_director'],
}
}

$catalogs.each |String $resource, Hash $attributes| {
bareos::director::catalog { $resource:
* => $attributes;
}
}
$clients.each |String $resource, Hash $attributes| {
bareos::director::client { $resource:
* => $attributes;
}
}
$consoles.each |String $resource, Hash $attributes| {
bareos::director::console { $resource:
* => $attributes;
}
}
$filesets.each |String $resource, Hash $attributes| {
bareos::director::fileset { $resource:
* => $attributes;
}
}
$jobs.each |String $resource, Hash $attributes| {
bareos::director::job { $resource:
* => $attributes;
}
}
$jobdefs.each |String $resource, Hash $attributes| {
bareos::director::jobdefs { $resource:
* => $attributes;
}
}
$messages.each |String $resource, Hash $attributes| {
bareos::director::messages { $resource:
* => $attributes;
}
}
$pools.each |String $resource, Hash $attributes| {
bareos::director::pool { $resource:
* => $attributes;
}
}
$profiles.each |String $resource, Hash $attributes| {
bareos::director::profile { $resource:
* => $attributes;
}
}
$schedules.each |String $resource, Hash $attributes| {
bareos::director::schedule { $resource:
* => $attributes;
}
}
$storages.each |String $resource, Hash $attributes| {
bareos::director::storage { $resource:
* => $attributes;
}
}
}
21 changes: 19 additions & 2 deletions spec/classes/director_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
require 'spec_helper'
describe 'bareos::director' do
let(:pre_condition) { 'class {"::bareos::director::director": password => "password" }' }

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
is_expected.to contain_bareos__director__catalog('test')
.with_db_driver('sqlite')
.with_db_name('test')
end
end
end