Skip to content

Commit 05c13ee

Browse files
committed
Enable neutron server to be run in SSL mode
This commit allows one to specify ca, cert and key file to run neutron server in SSL mode. Change-Id: I90f36e7c465924105e6b8032909988286f3e5374 (cherry picked from commit f48ce94)
1 parent d6896a6 commit 05c13ee

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed

manifests/init.pp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,22 @@
141141
# [*qpid_reconnect_interval_max*]
142142
# (optional) various QPID options
143143
#
144+
# [*use_ssl*]
145+
# (optinal) Enable SSL on the API server
146+
# Defaults to false, not set
147+
#
148+
# [*cert_file*]
149+
# (optinal) certificate file to use when starting api server securely
150+
# defaults to false, not set
151+
#
152+
# [*key_file*]
153+
# (optional) Private key file to use when starting API server securely
154+
# Defaults to false, not set
155+
#
156+
# [*ca_file*]
157+
# (optional) CA certificate file to use to verify connecting clients
158+
# Defaults to false, not set
159+
#
144160
# [*use_syslog*]
145161
# (optional) Use syslog for logging
146162
# Defaults to false
@@ -204,6 +220,10 @@
204220
$qpid_reconnect_interval_min = 0,
205221
$qpid_reconnect_interval_max = 0,
206222
$qpid_reconnect_interval = 0,
223+
$use_ssl = false,
224+
$cert_file = false,
225+
$key_file = false,
226+
$ca_file = false,
207227
$use_syslog = false,
208228
$log_facility = 'LOG_USER',
209229
$log_file = false,
@@ -214,6 +234,18 @@
214234

215235
Package['neutron'] -> Neutron_config<||>
216236

237+
if $use_ssl {
238+
if !$cert_file {
239+
fail('The cert_file parameter is required when use_ssl is set to true')
240+
}
241+
if !$ca_file {
242+
fail('The ca_file parameter is required when use_ssl is set to true')
243+
}
244+
if !$key_file {
245+
fail('The key_file parameter is required when use_ssl is set to true')
246+
}
247+
}
248+
217249
if $rabbit_use_ssl {
218250
if !$kombu_ssl_ca_certs {
219251
fail('The kombu_ssl_ca_certs parameter is required when rabbit_use_ssl is set to true')
@@ -350,6 +382,22 @@
350382
}
351383
}
352384

385+
# SSL Options
386+
neutron_config { 'DEFAULT/use_ssl' : value => $use_ssl; }
387+
if $use_ssl {
388+
neutron_config {
389+
'DEFAULT/ssl_cert_file' : value => $cert_file;
390+
'DEFAULT/ssl_key_file' : value => $key_file;
391+
'DEFAULT/ssl_ca_file' : value => $ca_file;
392+
}
393+
} else {
394+
neutron_config {
395+
'DEFAULT/ssl_cert_file': ensure => absent;
396+
'DEFAULT/ssl_key_file': ensure => absent;
397+
'DEFAULT/ssl_ca_file': ensure => absent;
398+
}
399+
}
400+
353401
if $use_syslog {
354402
neutron_config {
355403
'DEFAULT/use_syslog': value => true;

spec/classes/neutron_init_spec.rb

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
it_configures 'with SSL enabled'
5353
it_configures 'with SSL disabled'
5454
it_configures 'with SSL wrongly configured'
55+
it_configures 'with SSL socket options set'
56+
it_configures 'with SSL socket options set with wrong parameters'
57+
it_configures 'with SSL socket options set to false'
5558
it_configures 'with syslog disabled'
5659
it_configures 'with syslog enabled'
5760
it_configures 'with syslog enabled and custom settings'
@@ -135,6 +138,50 @@
135138
end
136139
end
137140

141+
shared_examples_for 'with SSL socket options set' do
142+
before do
143+
params.merge!(
144+
:use_ssl => true,
145+
:cert_file => '/path/to/cert',
146+
:key_file => '/path/to/key',
147+
:ca_file => '/path/to/ca'
148+
)
149+
end
150+
151+
it { should contain_neutron_config('DEFAULT/use_ssl').with_value('true') }
152+
it { should contain_neutron_config('DEFAULT/ssl_cert_file').with_value('/path/to/cert') }
153+
it { should contain_neutron_config('DEFAULT/ssl_key_file').with_value('/path/to/key') }
154+
it { should contain_neutron_config('DEFAULT/ssl_ca_file').with_value('/path/to/ca') }
155+
end
156+
157+
shared_examples_for 'with SSL socket options set with wrong parameters' do
158+
before do
159+
params.merge!(
160+
:use_ssl => true,
161+
:key_file => '/path/to/key',
162+
:ca_file => '/path/to/ca'
163+
)
164+
end
165+
166+
it_raises 'a Puppet::Error', /The cert_file parameter is required when use_ssl is set to true/
167+
end
168+
169+
shared_examples_for 'with SSL socket options set to false' do
170+
before do
171+
params.merge!(
172+
:use_ssl => false,
173+
:cert_file => false,
174+
:key_file => false,
175+
:ca_file => false
176+
)
177+
end
178+
179+
it { should contain_neutron_config('DEFAULT/use_ssl').with_value('false') }
180+
it { should contain_neutron_config('DEFAULT/ssl_cert_file').with_ensure('absent') }
181+
it { should contain_neutron_config('DEFAULT/ssl_key_file').with_ensure('absent') }
182+
it { should contain_neutron_config('DEFAULT/ssl_ca_file').with_ensure('absent') }
183+
end
184+
138185
shared_examples_for 'with syslog disabled' do
139186
it { should contain_neutron_config('DEFAULT/use_syslog').with_value(false) }
140187
end

0 commit comments

Comments
 (0)