Change config manifest

Config manifest changed after init commit according to freezer
project requirements.

Change-Id: Ibbfbacf105babb6115861a88f415cca7d15bff76
This commit is contained in:
Vitaliy 2017-04-03 13:09:25 +00:00
parent 2ca3c4a5a8
commit a0c78b75cb
4 changed files with 139 additions and 0 deletions

View File

@ -0,0 +1,27 @@
Puppet::Type.type(:freezer_api_paste_ini).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
) do
def section
resource[:name].split('/', 2).first
end
def setting
resource[:name].split('/', 2).last
end
def separator
'='
end
def self.file_path
'/etc/freezer/freezer-paste.ini'
end
# added for backwards compatibility with older versions of inifile
def file_path
self.class.file_path
end
end

View File

@ -0,0 +1,52 @@
Puppet::Type.newtype(:freezer_api_paste_ini) do
ensurable
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from /etc/freezer/freezer-paste.ini'
newvalues(/\S+\/\S+/)
end
newproperty(:value) do
desc 'The value of the setting to be defined.'
munge do |value|
value = value.to_s.strip
value.capitalize! if value =~ /^(true|false)$/i
value
end
def is_to_s( currentvalue )
if resource.secret?
return '[old secret redacted]'
else
return currentvalue
end
end
def should_to_s( newvalue )
if resource.secret?
return '[new secret redacted]'
else
return newvalue
end
end
end
newparam(:secret, :boolean => true) do
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
newvalues(:true, :false)
defaultto false
end
newparam(:ensure_absent_val) do
desc 'A value that is specified as the value property will behave as if ensure => absent was specified'
defaultto('<SERVICE DEFAULT>')
end
autorequire(:anchor) do
['freezer::install::end']
end
end

View File

@ -17,14 +17,26 @@
# DEFAULT/bar:
# value: barValue
#
# [*freezer_config*]
# (optional) Allow configuration of freezer.conf configurations.
# Defaults to empty hash'{}'
#
# [*api_paste_ini_config*]
# (optional) Allow configuration of /etc/freezer/freezer-paste.ini configurations.
#
# NOTE: The configuration MUST NOT be already handled by this module
# or Puppet catalog compilation will fail with duplicate resources.
#
class freezer::config (
$freezer_config = {},
$api_paste_ini_config = {},
) {
include ::freezer::deps
validate_hash($freezer_config)
validate_hash($api_paste_ini_config)
create_resources('freezer_config', $freezer_config)
create_resources('freezer_api_paste_ini', $api_paste_ini_config)
}

View File

@ -0,0 +1,48 @@
require 'spec_helper'
describe 'freezer::config' do
let(:config_hash) do {
'DEFAULT/foo' => { 'value' => 'fooValue' },
'DEFAULT/bar' => { 'value' => 'barValue' },
'DEFAULT/baz' => { 'ensure' => 'absent' }
}
end
shared_examples_for 'freezer_config' do
let :params do
{ :freezer_config => config_hash }
end
it 'configures arbitrary freezer-config configurations' do
is_expected.to contain_freezer_config('DEFAULT/foo').with_value('fooValue')
is_expected.to contain_freezer_config('DEFAULT/bar').with_value('barValue')
is_expected.to contain_freezer_config('DEFAULT/baz').with_ensure('absent')
end
end
shared_examples_for 'freezer_api_paste_ini' do
let :params do
{ :api_paste_ini_config => config_hash }
end
it 'configures arbitrary freezer-api-paste-ini configurations' do
is_expected.to contain_freezer_api_paste_ini('DEFAULT/foo').with_value('fooValue')
is_expected.to contain_freezer_api_paste_ini('DEFAULT/bar').with_value('barValue')
is_expected.to contain_freezer_api_paste_ini('DEFAULT/baz').with_ensure('absent')
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'freezer_config'
it_configures 'freezer_api_paste_ini'
end
end
end