Merge "Makes kombu_ssl_* parameters optional when rabbit_use_ssl => true"

This commit is contained in:
Jenkins 2015-02-04 13:28:34 +00:00 committed by Gerrit Code Review
commit 553d098745
2 changed files with 33 additions and 23 deletions

View File

@ -60,18 +60,6 @@ class glance::notify::rabbitmq(
$amqp_durable_queues_real = $amqp_durable_queues $amqp_durable_queues_real = $amqp_durable_queues
} }
if $rabbit_use_ssl {
if !$kombu_ssl_ca_certs {
fail('The kombu_ssl_ca_certs parameter is required when rabbit_use_ssl is set to true')
}
if !$kombu_ssl_certfile {
fail('The kombu_ssl_certfile parameter is required when rabbit_use_ssl is set to true')
}
if !$kombu_ssl_keyfile {
fail('The kombu_ssl_keyfile parameter is required when rabbit_use_ssl is set to true')
}
}
if $rabbit_hosts { if $rabbit_hosts {
glance_api_config { glance_api_config {
'DEFAULT/rabbit_hosts': value => join($rabbit_hosts, ','); 'DEFAULT/rabbit_hosts': value => join($rabbit_hosts, ',');
@ -98,19 +86,34 @@ class glance::notify::rabbitmq(
} }
if $rabbit_use_ssl { if $rabbit_use_ssl {
glance_api_config { glance_api_config { 'DEFAULT/kombu_ssl_version': value => $kombu_ssl_version }
'DEFAULT/kombu_ssl_ca_certs': value => $kombu_ssl_ca_certs;
'DEFAULT/kombu_ssl_certfile': value => $kombu_ssl_certfile; if $kombu_ssl_ca_certs {
'DEFAULT/kombu_ssl_keyfile': value => $kombu_ssl_keyfile; glance_api_config { 'DEFAULT/kombu_ssl_ca_certs': value => $kombu_ssl_ca_certs }
'DEFAULT/kombu_ssl_version': value => $kombu_ssl_version; } else {
glance_api_config { 'DEFAULT/kombu_ssl_ca_certs': ensure => absent}
}
if $kombu_ssl_certfile {
glance_api_config { 'DEFAULT/kombu_ssl_certfile': value => $kombu_ssl_certfile }
} else {
glance_api_config { 'DEFAULT/kombu_ssl_certfile': ensure => absent}
}
if $kombu_ssl_keyfile {
glance_api_config { 'DEFAULT/kombu_ssl_keyfile': value => $kombu_ssl_keyfile }
} else {
glance_api_config { 'DEFAULT/kombu_ssl_keyfile': ensure => absent}
} }
} else { } else {
glance_api_config { glance_api_config {
'DEFAULT/kombu_ssl_version': ensure => absent;
'DEFAULT/kombu_ssl_ca_certs': ensure => absent; 'DEFAULT/kombu_ssl_ca_certs': ensure => absent;
'DEFAULT/kombu_ssl_certfile': ensure => absent; 'DEFAULT/kombu_ssl_certfile': ensure => absent;
'DEFAULT/kombu_ssl_keyfile': ensure => absent; 'DEFAULT/kombu_ssl_keyfile': ensure => absent;
'DEFAULT/kombu_ssl_version': ensure => absent; }
if ($kombu_ssl_keyfile or $kombu_ssl_certfile or $kombu_ssl_ca_certs) {
notice('Configuration of certificates with $rabbit_use_ssl == false is a useless config')
} }
} }
} }

View File

@ -28,18 +28,24 @@ describe 'glance::notify::rabbitmq' do
it { should contain_glance_api_config('DEFAULT/rabbit_notification_topic').with_value('notifications') } it { should contain_glance_api_config('DEFAULT/rabbit_notification_topic').with_value('notifications') }
end end
describe 'when passing params' do describe 'when passing params and use ssl' do
let :params do let :params do
{ {
:rabbit_password => 'pass', :rabbit_password => 'pass',
:rabbit_userid => 'guest2', :rabbit_userid => 'guest2',
:rabbit_host => 'localhost2', :rabbit_host => 'localhost2',
:rabbit_port => '5673', :rabbit_port => '5673',
:rabbit_use_ssl => true,
:rabbit_durable_queues => true, :rabbit_durable_queues => true,
} }
it { should contain_glance_api_config('DEFAULT/rabbit_userid').with_value('guest2') } it { should contain_glance_api_config('DEFAULT/rabbit_userid').with_value('guest2') }
it { should contain_glance_api_config('DEFAULT/rabbit_host').with_value('localhost2') } it { should contain_glance_api_config('DEFAULT/rabbit_host').with_value('localhost2') }
it { should contain_glance_api_config('DEFAULT/rabbit_port').with_value('5673') } it { should contain_glance_api_config('DEFAULT/rabbit_port').with_value('5673') }
it { should contain_glance_api_config('DEFAULT/rabbit_use_ssl').with_value('true') }
it { should contain_glance_api_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent') }
it { should contain_glance_api_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent') }
it { should contain_glance_api_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent') }
it { should contain_glance_api_config('DEFAULT/kombu_ssl_version').with_value('TLSv1') }
it { should contain_glance_api_config('DEFAULT/rabbit_durable_queues').with_value('true') } it { should contain_glance_api_config('DEFAULT/rabbit_durable_queues').with_value('true') }
end end
end end
@ -47,7 +53,7 @@ describe 'glance::notify::rabbitmq' do
describe 'with rabbit ssl cert parameters' do describe 'with rabbit ssl cert parameters' do
let :params do let :params do
{ {
:rabbit_password => 'pass', :rabbit_password => 'pass',
:rabbit_use_ssl => 'true', :rabbit_use_ssl => 'true',
:kombu_ssl_ca_certs => '/etc/ca.cert', :kombu_ssl_ca_certs => '/etc/ca.cert',
:kombu_ssl_certfile => '/etc/certfile', :kombu_ssl_certfile => '/etc/certfile',
@ -55,8 +61,7 @@ describe 'glance::notify::rabbitmq' do
:kombu_ssl_version => 'TLSv1', :kombu_ssl_version => 'TLSv1',
} }
end end
it { should contain_glance_api_config('DEFAULT/rabbit_use_ssl').with_value(true) }
it { should contain_glance_api_config('DEFAULT/rabbit_use_ssl').with_value('true') }
it { should contain_glance_api_config('DEFAULT/kombu_ssl_ca_certs').with_value('/etc/ca.cert') } it { should contain_glance_api_config('DEFAULT/kombu_ssl_ca_certs').with_value('/etc/ca.cert') }
it { should contain_glance_api_config('DEFAULT/kombu_ssl_certfile').with_value('/etc/certfile') } it { should contain_glance_api_config('DEFAULT/kombu_ssl_certfile').with_value('/etc/certfile') }
it { should contain_glance_api_config('DEFAULT/kombu_ssl_keyfile').with_value('/etc/key') } it { should contain_glance_api_config('DEFAULT/kombu_ssl_keyfile').with_value('/etc/key') }
@ -89,6 +94,7 @@ describe 'glance::notify::rabbitmq' do
:rabbit_userid => 'guest2', :rabbit_userid => 'guest2',
:rabbit_host => 'localhost2', :rabbit_host => 'localhost2',
:rabbit_port => '5673', :rabbit_port => '5673',
:rabbit_use_ssl => true,
:rabbit_durable_queues => true, :rabbit_durable_queues => true,
} }
end end
@ -96,6 +102,7 @@ describe 'glance::notify::rabbitmq' do
it { should contain_glance_api_config('DEFAULT/rabbit_host').with_value('localhost2') } it { should contain_glance_api_config('DEFAULT/rabbit_host').with_value('localhost2') }
it { should contain_glance_api_config('DEFAULT/rabbit_port').with_value('5673') } it { should contain_glance_api_config('DEFAULT/rabbit_port').with_value('5673') }
it { should contain_glance_api_config('DEFAULT/rabbit_hosts').with_value('localhost2:5673') } it { should contain_glance_api_config('DEFAULT/rabbit_hosts').with_value('localhost2:5673') }
it { should contain_glance_api_config('DEFAULT/rabbit_use_ssl').with_value('true') }
it { should contain_glance_api_config('DEFAULT/amqp_durable_queues').with_value('true') } it { should contain_glance_api_config('DEFAULT/amqp_durable_queues').with_value('true') }
end end