From 02547a399ce9ec887b23277ab3b168c7fc413da6 Mon Sep 17 00:00:00 2001 From: ZhongShengping Date: Wed, 27 Apr 2016 16:18:37 +0800 Subject: [PATCH] Add the capability to configure api-paste.ini with config.pp Already added type/provider for paste configs, but it wouldn't to patch ec2api::config. Change-Id: Id1f9a537a73c9cb1d038ce9015bb5da76f827878 --- manifests/config.pp | 8 +++++++- spec/classes/ec2api_config_spec.rb | 31 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 spec/classes/ec2api_config_spec.rb diff --git a/manifests/config.pp b/manifests/config.pp index 363c784..5b08ec5 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -17,14 +17,20 @@ # DEFAULT/bar: # value: barValue # +# [*ec2api_api_paste_ini*] +# (optional) Allow configuration of /etc/ec2api/api-paste.ini options. +# # NOTE: The configuration MUST NOT be already handled by this module # or Puppet catalog compilation will fail with duplicate resources. # class ec2api::config ( - $ec2api_config = {}, + $ec2api_config = {}, + $ec2api_api_paste_ini = {}, ) { validate_hash($ec2api_config) + validate_hash($ec2api_api_paste_ini) create_resources('ec2api_config', $ec2api_config) + create_resources('ec2api_api_paste_ini', $ec2api_api_paste_ini) } diff --git a/spec/classes/ec2api_config_spec.rb b/spec/classes/ec2api_config_spec.rb new file mode 100644 index 0000000..7a32f4e --- /dev/null +++ b/spec/classes/ec2api_config_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' + +describe 'ec2api::config' do + + let :params do + { :ec2api_config => { + 'DEFAULT/foo' => { 'value' => 'fooValue' }, + 'DEFAULT/bar' => { 'value' => 'barValue' }, + 'DEFAULT/baz' => { 'ensure' => 'absent' } + }, + :ec2api_api_paste_ini => { + 'DEFAULT/foo2' => { 'value' => 'fooValue' }, + 'DEFAULT/bar2' => { 'value' => 'barValue' }, + 'DEFAULT/baz2' => { 'ensure' => 'absent' } + } + } + end + + it 'configures arbitrary ec2api configurations' do + is_expected.to contain_ec2api_config('DEFAULT/foo').with_value('fooValue') + is_expected.to contain_ec2api_config('DEFAULT/bar').with_value('barValue') + is_expected.to contain_ec2api_config('DEFAULT/baz').with_ensure('absent') + end + + it 'configures arbitrary ec2api-api-paste configurations' do + is_expected.to contain_ec2api_api_paste_ini('DEFAULT/foo2').with_value('fooValue') + is_expected.to contain_ec2api_api_paste_ini('DEFAULT/bar2').with_value('barValue') + is_expected.to contain_ec2api_api_paste_ini('DEFAULT/baz2').with_ensure('absent') + end + +end