diff --git a/manifests/config.pp b/manifests/config.pp index dccb29a6..96f71956 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -29,6 +29,12 @@ # [*registry_paste_ini_config*] # (optional) Allow configuration of glance-registry-paste.ini configurations. # +# [*glare_config*] +# (optional) Allow configuration of glance-glare.conf configurations. +# +# [*glare_paste_ini_config*] +# (optional) Allow configuration of glance-glare-paste.ini configurations. +# # [*cache_config*] # (optional) Allow configuration of glance-cache.conf configurations. # @@ -40,6 +46,8 @@ class glance::config ( $api_paste_ini_config = {}, $registry_config = {}, $registry_paste_ini_config = {}, + $glare_config = {}, + $glare_paste_ini_config = {}, $cache_config = {}, ) { validate_hash($api_config) @@ -47,10 +55,14 @@ class glance::config ( validate_hash($registry_config) validate_hash($registry_paste_ini_config) validate_hash($cache_config) + validate_hash($glare_config) + validate_hash($glare_paste_ini_config) create_resources('glance_api_config', $api_config) create_resources('glance_api_paste_ini', $api_paste_ini_config) create_resources('glance_registry_config', $registry_config) create_resources('glance_registry_paste_ini', $registry_paste_ini_config) create_resources('glance_cache_config', $cache_config) + create_resources('glance_glare_config', $glare_config) + create_resources('glance_glare_paste_ini', $glare_paste_ini_config) } diff --git a/spec/acceptance/glance_config_spec.rb b/spec/acceptance/glance_config_spec.rb index 8910394f..6074cfe5 100644 --- a/spec/acceptance/glance_config_spec.rb +++ b/spec/acceptance/glance_config_spec.rb @@ -11,6 +11,7 @@ describe 'basic glance config resource' do File <||> -> Glance_api_config <||> File <||> -> Glance_registry_config <||> File <||> -> Glance_cache_config <||> + File <||> -> Glance_glare_config <||> file { '/etc/glance' : ensure => directory, @@ -24,6 +25,9 @@ describe 'basic glance config resource' do file { '/etc/glance/glance-cache.conf' : ensure => file, } + file { '/etc/glance/glance-glare.conf' : + ensure => file, + } glance_api_config { 'DEFAULT/thisshouldexist' : value => 'foo', @@ -78,6 +82,24 @@ describe 'basic glance config resource' do value => 'toto', ensure_absent_val => 'toto', } + + glance_glare_config { 'DEFAULT/thisshouldexist' : + value => 'foo', + } + + glance_glare_config { 'DEFAULT/thisshouldnotexist' : + value => '', + } + + glance_glare_config { 'DEFAULT/thisshouldexist2' : + value => '', + ensure_absent_val => 'toto', + } + + glance_glare_config { 'DEFAULT/thisshouldnotexist2' : + value => 'toto', + ensure_absent_val => 'toto', + } EOS @@ -118,5 +140,16 @@ describe 'basic glance config resource' do it { is_expected.not_to match /thisshouldnotexist/ } end end + + describe file('/etc/glance/glance-glare.conf') do + it { is_expected.to exist } + it { is_expected.to contain('thisshouldexist=foo') } + it { is_expected.to contain('thisshouldexist2=') } + + describe '#content' do + subject { super().content } + it { is_expected.not_to match /thisshouldnotexist/ } + end + end end end diff --git a/spec/classes/glance_config_spec.rb b/spec/classes/glance_config_spec.rb new file mode 100644 index 00000000..4245bed4 --- /dev/null +++ b/spec/classes/glance_config_spec.rb @@ -0,0 +1,95 @@ +require 'spec_helper' + +describe 'glance::config' do + + let(:config_hash) do { + 'DEFAULT/foo' => { 'value' => 'fooValue' }, + 'DEFAULT/bar' => { 'value' => 'barValue' }, + 'DEFAULT/baz' => { 'ensure' => 'absent' } + } + end + + shared_examples_for 'glance_api_config' do + let :params do + { :api_config => config_hash, + :api_paste_ini_config => config_hash } + end + + it 'configures arbitrary glance-api configurations' do + is_expected.to contain_glance_api_config('DEFAULT/foo').with_value('fooValue') + is_expected.to contain_glance_api_config('DEFAULT/bar').with_value('barValue') + is_expected.to contain_glance_api_config('DEFAULT/baz').with_ensure('absent') + end + + it 'configures arbitrary glance-api-paste configurations' do + is_expected.to contain_glance_api_paste_ini('DEFAULT/foo').with_value('fooValue') + is_expected.to contain_glance_api_paste_ini('DEFAULT/bar').with_value('barValue') + is_expected.to contain_glance_api_paste_ini('DEFAULT/baz').with_ensure('absent') + end + end + + shared_examples_for 'glance_registry_config' do + let :params do + { :registry_config => config_hash, + :registry_paste_ini_config => config_hash } + end + + it 'configures arbitrary glance-registry configurations' do + is_expected.to contain_glance_registry_config('DEFAULT/foo').with_value('fooValue') + is_expected.to contain_glance_registry_config('DEFAULT/bar').with_value('barValue') + is_expected.to contain_glance_registry_config('DEFAULT/baz').with_ensure('absent') + end + + it 'configures arbitrary glance-registry-paste configurations' do + is_expected.to contain_glance_registry_paste_ini('DEFAULT/foo').with_value('fooValue') + is_expected.to contain_glance_registry_paste_ini('DEFAULT/bar').with_value('barValue') + is_expected.to contain_glance_registry_paste_ini('DEFAULT/baz').with_ensure('absent') + end + end + + shared_examples_for 'glance_glare_config' do + let :params do + { :glare_config => config_hash, + :glare_paste_ini_config => config_hash } + end + + it 'configures arbitrary glance-glare configurations' do + is_expected.to contain_glance_glare_config('DEFAULT/foo').with_value('fooValue') + is_expected.to contain_glance_glare_config('DEFAULT/bar').with_value('barValue') + is_expected.to contain_glance_glare_config('DEFAULT/baz').with_ensure('absent') + end + + it 'configures arbitrary glance-glare-paste configurations' do + is_expected.to contain_glance_glare_paste_ini('DEFAULT/foo').with_value('fooValue') + is_expected.to contain_glance_glare_paste_ini('DEFAULT/bar').with_value('barValue') + is_expected.to contain_glance_glare_paste_ini('DEFAULT/baz').with_ensure('absent') + end + end + + shared_examples_for 'glance_cache_config' do + let :params do + { :cache_config => config_hash } + end + + it 'configures arbitrary glance-cache configurations' do + is_expected.to contain_glance_cache_config('DEFAULT/foo').with_value('fooValue') + is_expected.to contain_glance_cache_config('DEFAULT/bar').with_value('barValue') + is_expected.to contain_glance_cache_config('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 'glance_api_config' + it_configures 'glance_registry_config' + it_configures 'glance_glare_config' + it_configures 'glance_cache_config' + end + end +end