Skip to content

Commit 240b119

Browse files
committed
Enable cinder server to be run in SSL mode
This commit allows one to specify ca, cert and key file to run cinder server in SSL mode Note: The flag use_ssl per se is not used in cinder yet, its purpose here it to verify collateral parameters. Change-Id: Icc373830421f2254692eb8c7baad05a13e6e1e76 (cherry picked from commit 131108a)
1 parent 57da044 commit 240b119

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed

manifests/init.pp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@
2626
# If set to boolean false, it will not log to any directory.
2727
# Defaults to '/var/log/cinder'
2828
#
29+
# [*use_ssl*]
30+
# (optional) Enable SSL on the API server
31+
# Defaults to false, not set
32+
#
33+
# [*cert_file*]
34+
# (optinal) Certificate file to use when starting API server securely
35+
# Defaults to false, not set
36+
#
37+
# [*key_file*]
38+
# (optional) Private key file to use when starting API server securely
39+
# Defaults to false, not set
40+
#
41+
# [*ca_file*]
42+
# (optional) CA certificate file to use to verify connecting clients
43+
# Defaults to false, not set_
44+
#
2945
# [*mysql_module*]
3046
# (optional) Puppetlabs-mysql module version to use
3147
# Tested versions include 0.9 and 2.2
@@ -63,6 +79,10 @@
6379
$qpid_protocol = 'tcp',
6480
$qpid_tcp_nodelay = true,
6581
$package_ensure = 'present',
82+
$use_ssl = false,
83+
$ca_file = false,
84+
$cert_file = false,
85+
$key_file = false,
6686
$api_paste_config = '/etc/cinder/api-paste.ini',
6787
$use_syslog = false,
6888
$log_facility = 'LOG_USER',
@@ -94,6 +114,15 @@
94114
$database_idle_timeout_real = $database_idle_timeout
95115
}
96116

117+
if $use_ssl {
118+
if !$cert_file {
119+
fail('The cert_file parameter is required when use_ssl is set to true')
120+
}
121+
if !$key_file {
122+
fail('The key_file parameter is required when use_ssl is set to true')
123+
}
124+
}
125+
97126
# this anchor is used to simplify the graph between cinder components by
98127
# allowing a resource to serve as a point where the configuration of cinder begins
99128
anchor { 'cinder-start': }
@@ -217,6 +246,29 @@
217246
}
218247
}
219248

249+
# SSL Options
250+
if $use_ssl {
251+
cinder_config {
252+
'DEFAULT/ssl_cert_file' : value => $cert_file;
253+
'DEFAULT/ssl_key_file' : value => $key_file;
254+
}
255+
if $ca_file {
256+
cinder_config { 'DEFAULT/ssl_ca_file' :
257+
value => $ca_file,
258+
}
259+
} else {
260+
cinder_config { 'DEFAULT/ssl_ca_file' :
261+
ensure => absent,
262+
}
263+
}
264+
} else {
265+
cinder_config {
266+
'DEFAULT/ssl_cert_file' : ensure => absent;
267+
'DEFAULT/ssl_key_file' : ensure => absent;
268+
'DEFAULT/ssl_ca_file' : ensure => absent;
269+
}
270+
}
271+
220272
if $use_syslog {
221273
cinder_config {
222274
'DEFAULT/use_syslog': value => true;

spec/classes/cinder_spec.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,54 @@
248248
it { should_not contain_class('mysql::bindings') }
249249
it { should_not contain_class('mysql::bindings::python') }
250250
end
251+
252+
describe 'with SSL socket options set' do
253+
let :params do
254+
{
255+
:use_ssl => true,
256+
:cert_file => '/path/to/cert',
257+
:ca_file => '/path/to/ca',
258+
:key_file => '/path/to/key',
259+
:rabbit_password => 'guest',
260+
}
261+
end
262+
263+
it { should contain_cinder_config('DEFAULT/ssl_ca_file').with_value('/path/to/ca') }
264+
it { should contain_cinder_config('DEFAULT/ssl_cert_file').with_value('/path/to/cert') }
265+
it { should contain_cinder_config('DEFAULT/ssl_key_file').with_value('/path/to/key') }
266+
end
267+
268+
describe 'with SSL socket options set to false' do
269+
let :params do
270+
{
271+
:use_ssl => false,
272+
:cert_file => false,
273+
:ca_file => false,
274+
:key_file => false,
275+
:rabbit_password => 'guest',
276+
}
277+
end
278+
279+
it { should contain_cinder_config('DEFAULT/ssl_ca_file').with_ensure('absent') }
280+
it { should contain_cinder_config('DEFAULT/ssl_cert_file').with_ensure('absent') }
281+
it { should contain_cinder_config('DEFAULT/ssl_key_file').with_ensure('absent') }
282+
end
283+
284+
describe 'with SSL socket options set wrongly configured' do
285+
let :params do
286+
{
287+
:use_ssl => true,
288+
:ca_file => '/path/to/ca',
289+
:key_file => '/path/to/key',
290+
:rabbit_password => 'guest',
291+
}
292+
end
293+
294+
it 'should raise an error' do
295+
expect {
296+
should compile
297+
}.to raise_error Puppet::Error, /The cert_file parameter is required when use_ssl is set to true/
298+
end
299+
end
300+
251301
end

0 commit comments

Comments
 (0)