Skip to content

Commit 141e65a

Browse files
author
Mike Dorman
committed
Makes kombu_ssl_* parameters optional when rabbit_use_ssl => true
The kombu_ssl_* parameters should not be required when rabbit_use_ssl => true Rather, rabbit_use_ssl must be set to true if the kombu_ssl_* parameters are used. Change-Id: Ia3d71eaccdfb736068478b935e5be46719eb49db Closes-Bug: 1356083
1 parent a929c14 commit 141e65a

File tree

2 files changed

+83
-32
lines changed

2 files changed

+83
-32
lines changed

manifests/init.pp

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,17 @@
257257
fail('The ca_file parameter requires that use_ssl to be set to true')
258258
}
259259

260-
if $rabbit_use_ssl {
261-
if !$kombu_ssl_ca_certs {
262-
fail('The kombu_ssl_ca_certs parameter is required when rabbit_use_ssl is set to true')
263-
}
264-
if !$kombu_ssl_certfile {
265-
fail('The kombu_ssl_certfile parameter is required when rabbit_use_ssl is set to true')
266-
}
267-
if !$kombu_ssl_keyfile {
268-
fail('The kombu_ssl_keyfile parameter is required when rabbit_use_ssl is set to true')
269-
}
260+
if $kombu_ssl_ca_certs and !$rabbit_use_ssl {
261+
fail('The kombu_ssl_ca_certs parameter requires rabbit_use_ssl to be set to true')
262+
}
263+
if $kombu_ssl_certfile and !$rabbit_use_ssl {
264+
fail('The kombu_ssl_certfile parameter requires rabbit_use_ssl to be set to true')
265+
}
266+
if $kombu_ssl_keyfile and !$rabbit_use_ssl {
267+
fail('The kombu_ssl_keyfile parameter requires rabbit_use_ssl to be set to true')
268+
}
269+
if ($kombu_ssl_certfile and !$kombu_ssl_keyfile) or ($kombu_ssl_keyfile and !$kombu_ssl_certfile) {
270+
fail('The kombu_ssl_certfile and kombu_ssl_keyfile parameters must be used together')
270271
}
271272

272273
File {
@@ -370,12 +371,31 @@
370371
}
371372

372373
if $rabbit_use_ssl {
373-
neutron_config {
374-
'DEFAULT/kombu_ssl_ca_certs': value => $kombu_ssl_ca_certs;
375-
'DEFAULT/kombu_ssl_certfile': value => $kombu_ssl_certfile;
376-
'DEFAULT/kombu_ssl_keyfile': value => $kombu_ssl_keyfile;
377-
'DEFAULT/kombu_ssl_version': value => $kombu_ssl_version;
374+
375+
if $kombu_ssl_ca_certs {
376+
neutron_config { 'DEFAULT/kombu_ssl_ca_certs': value => $kombu_ssl_ca_certs; }
377+
} else {
378+
neutron_config { 'DEFAULT/kombu_ssl_ca_certs': ensure => absent; }
379+
}
380+
381+
if $kombu_ssl_certfile or $kombu_ssl_keyfile {
382+
neutron_config {
383+
'DEFAULT/kombu_ssl_certfile': value => $kombu_ssl_certfile;
384+
'DEFAULT/kombu_ssl_keyfile': value => $kombu_ssl_keyfile;
385+
}
386+
} else {
387+
neutron_config {
388+
'DEFAULT/kombu_ssl_certfile': ensure => absent;
389+
'DEFAULT/kombu_ssl_keyfile': ensure => absent;
390+
}
378391
}
392+
393+
if $kombu_ssl_version {
394+
neutron_config { 'DEFAULT/kombu_ssl_version': value => $kombu_ssl_version; }
395+
} else {
396+
neutron_config { 'DEFAULT/kombu_ssl_version': ensure => absent; }
397+
}
398+
379399
} else {
380400
neutron_config {
381401
'DEFAULT/kombu_ssl_ca_certs': ensure => absent;

spec/classes/neutron_init_spec.rb

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@
4949

5050
end
5151

52-
it_configures 'with SSL enabled'
52+
it_configures 'with SSL enabled with kombu'
53+
it_configures 'with SSL enabled without kombu'
5354
it_configures 'with SSL disabled'
5455
it_configures 'with SSL wrongly configured'
56+
it_configures 'with SSL and kombu wrongly configured'
5557
it_configures 'with SSL socket options set'
5658
it_configures 'with SSL socket options set with wrong parameters'
5759
it_configures 'with SSL socket options set to false'
@@ -215,7 +217,7 @@
215217
it { should contain_neutron_config('DEFAULT/use_syslog').with_value(false) }
216218
end
217219

218-
shared_examples_for 'with SSL enabled' do
220+
shared_examples_for 'with SSL enabled with kombu' do
219221
before do
220222
params.merge!(
221223
:rabbit_use_ssl => true,
@@ -235,13 +237,26 @@
235237
end
236238
end
237239

240+
shared_examples_for 'with SSL enabled without kombu' do
241+
before do
242+
params.merge!(
243+
:rabbit_use_ssl => true
244+
)
245+
end
246+
247+
it do
248+
should contain_neutron_config('DEFAULT/rabbit_use_ssl').with_value('true')
249+
should contain_neutron_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent')
250+
should contain_neutron_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent')
251+
should contain_neutron_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent')
252+
should contain_neutron_config('DEFAULT/kombu_ssl_version').with_value('SSLv3')
253+
end
254+
end
255+
238256
shared_examples_for 'with SSL disabled' do
239257
before do
240258
params.merge!(
241259
:rabbit_use_ssl => false,
242-
:kombu_ssl_ca_certs => 'undef',
243-
:kombu_ssl_certfile => 'undef',
244-
:kombu_ssl_keyfile => 'undef',
245260
:kombu_ssl_version => 'SSLv3'
246261
)
247262
end
@@ -258,28 +273,44 @@
258273
shared_examples_for 'with SSL wrongly configured' do
259274
before do
260275
params.merge!(
261-
:rabbit_use_ssl => true,
262-
:kombu_ssl_ca_certs => 'undef',
263-
:kombu_ssl_certfile => 'undef',
264-
:kombu_ssl_keyfile => 'undef'
276+
:rabbit_use_ssl => false
265277
)
266278
end
267279

268-
context 'without required parameters' do
280+
context 'with SSL disabled' do
281+
282+
context 'with kombu_ssl_ca_certs parameter' do
283+
before { params.merge!(:kombu_ssl_ca_certs => '/path/to/ssl/ca/certs') }
284+
it_raises 'a Puppet::Error', /The kombu_ssl_ca_certs parameter requires rabbit_use_ssl to be set to true/
285+
end
269286

270-
context 'without kombu_ssl_ca_certs parameter' do
271-
before { params.delete(:kombu_ssl_ca_certs) }
272-
it_raises 'a Puppet::Error', /The kombu_ssl_ca_certs parameter is required when rabbit_use_ssl is set to true/
287+
context 'with kombu_ssl_certfile parameter' do
288+
before { params.merge!(:kombu_ssl_certfile => '/path/to/ssl/cert/file') }
289+
it_raises 'a Puppet::Error', /The kombu_ssl_certfile parameter requires rabbit_use_ssl to be set to true/
273290
end
274291

275-
context 'without kombu_ssl_certfile parameter' do
276-
before { params.delete(:kombu_ssl_certfile) }
277-
it_raises 'a Puppet::Error', /The kombu_ssl_certfile parameter is required when rabbit_use_ssl is set to true/
292+
context 'with kombu_ssl_keyfile parameter' do
293+
before { params.merge!(:kombu_ssl_keyfile => '/path/to/ssl/keyfile') }
294+
it_raises 'a Puppet::Error', /The kombu_ssl_keyfile parameter requires rabbit_use_ssl to be set to true/
278295
end
296+
end
297+
298+
end
299+
300+
shared_examples_for 'with SSL and kombu wrongly configured' do
301+
before do
302+
params.merge!(
303+
:rabbit_use_ssl => true,
304+
:kombu_ssl_certfile => '/path/to/ssl/cert/file',
305+
:kombu_ssl_keyfile => '/path/to/ssl/keyfile'
306+
)
307+
end
308+
309+
context 'without required parameters' do
279310

280311
context 'without kombu_ssl_keyfile parameter' do
281312
before { params.delete(:kombu_ssl_keyfile) }
282-
it_raises 'a Puppet::Error', /The kombu_ssl_keyfile parameter is required when rabbit_use_ssl is set to true/
313+
it_raises 'a Puppet::Error', /The kombu_ssl_certfile and kombu_ssl_keyfile parameters must be used together/
283314
end
284315
end
285316

0 commit comments

Comments
 (0)