Add sahara::config class
Other modules provide an X::config class to be able to specify parameters that are not yet part of the module. Sahara was missing this feature. This commit aims to add it for puppet-sahara. Change-Id: Ie8bf79783ae32648dd10792de6d76eeb84877302
This commit is contained in:
parent
0495a7da0d
commit
9c8d604ac1
30
manifests/config.pp
Normal file
30
manifests/config.pp
Normal file
@ -0,0 +1,30 @@
|
||||
# == Class: sahara::config
|
||||
#
|
||||
# This class is used to manage arbitrary Sahara configurations.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*sahara_config*]
|
||||
# (optional) Allow configuration of arbitrary Sahara configurations.
|
||||
# The value is an hash of sahara_config resources. Example:
|
||||
# { 'DEFAULT/foo' => { value => 'fooValue'},
|
||||
# 'DEFAULT/bar' => { value => 'barValue'}
|
||||
# }
|
||||
# In yaml format, Example:
|
||||
# sahara_config:
|
||||
# DEFAULT/foo:
|
||||
# value: fooValue
|
||||
# DEFAULT/bar:
|
||||
# value: barValue
|
||||
#
|
||||
# NOTE: The configuration MUST NOT be already handled by this module
|
||||
# or Puppet catalog compilation will fail with duplicate resources.
|
||||
#
|
||||
class sahara::config (
|
||||
$sahara_config = {},
|
||||
) {
|
||||
|
||||
validate_hash($sahara_config)
|
||||
|
||||
create_resources('sahara_config', $sahara_config)
|
||||
}
|
20
spec/classes/sahara_config_spec.rb
Normal file
20
spec/classes/sahara_config_spec.rb
Normal file
@ -0,0 +1,20 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'sahara::config' do
|
||||
|
||||
let :params do
|
||||
{ :sahara_config => {
|
||||
'DEFAULT/foo' => { 'value' => 'fooValue' },
|
||||
'DEFAULT/bar' => { 'value' => 'barValue' },
|
||||
'DEFAULT/baz' => { 'ensure' => 'absent' }
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
it 'configures arbitrary sahara configurations' do
|
||||
is_expected.to contain_sahara_config('DEFAULT/foo').with_value('fooValue')
|
||||
is_expected.to contain_sahara_config('DEFAULT/bar').with_value('barValue')
|
||||
is_expected.to contain_sahara_config('DEFAULT/baz').with_ensure('absent')
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user