make auth_encryption_key a parameter
Also add tests for heat::engine Change-Id: Ic84344060eaad006026fb6b66d569efa3d2592e3 Closes-Bug: #1249280
This commit is contained in:
parent
51816260b9
commit
9a885b068b
|
@ -20,6 +20,7 @@ node default {
|
|||
|
||||
# Install heat-engine
|
||||
class { 'heat::engine':
|
||||
auth_encryption_key => 'whatever-key-you-like',
|
||||
}
|
||||
|
||||
# Install the heat-api service
|
||||
|
|
|
@ -1,6 +1,34 @@
|
|||
# Installs & configure the heat engine service
|
||||
# Class heat::engine
|
||||
#
|
||||
# Installs & configure the heat engine service
|
||||
#
|
||||
# == parameters
|
||||
# [*enabled*]
|
||||
# (optional) The state of the service
|
||||
# Defaults to true
|
||||
#
|
||||
# [*heat_stack_user_role*]
|
||||
# (optional) Keystone role for heat template-defined users
|
||||
# Defaults to 'heat_stack_user'
|
||||
#
|
||||
# [*heat_metadata_server_url*]
|
||||
# (optional) URL of the Heat metadata server
|
||||
# Defaults to 'http://127.0.0.1:8000'
|
||||
#
|
||||
# [*heat_waitcondition_server_url*]
|
||||
# (optional) URL of the Heat waitcondition server
|
||||
# Defaults to 'http://127.0.0.1:8000/v1/waitcondition'
|
||||
#
|
||||
# [*heat_watch_server_url*]
|
||||
# (optional) URL of the Heat cloudwatch server
|
||||
# Defaults to 'http://127.0.0.1:8003'
|
||||
#
|
||||
# [*auth_encryption_key*]
|
||||
# (required) Encryption key used for authentication info in database
|
||||
#
|
||||
|
||||
class heat::engine (
|
||||
$auth_encryption_key,
|
||||
$enabled = true,
|
||||
$heat_stack_user_role = 'heat_stack_user',
|
||||
$heat_metadata_server_url = 'http://127.0.0.1:8000',
|
||||
|
@ -32,21 +60,13 @@ class heat::engine (
|
|||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
require => [ File['/etc/heat/heat.conf'],
|
||||
Exec['heat-encryption-key-replacement'],
|
||||
Package['heat-common'],
|
||||
Package['heat-engine']],
|
||||
subscribe => Exec['heat-dbsync'],
|
||||
}
|
||||
|
||||
exec {'heat-encryption-key-replacement':
|
||||
command => 'sed -i".bak" "s/%ENCRYPTION_KEY%/`hexdump -n 16 -v -e \'/1 "%02x"\' /dev/random`/" /etc/heat/heat.conf',
|
||||
path => [ '/usr/bin', '/bin'],
|
||||
onlyif => 'grep -c %ENCRYPTION_KEY% /etc/heat/heat.conf',
|
||||
require => File['/etc/heat/heat.conf'],
|
||||
}
|
||||
|
||||
heat_config {
|
||||
'DEFAULT/auth_encryption_key' : value => '%ENCRYPTION_KEY%'; # replaced above
|
||||
'DEFAULT/auth_encryption_key' : value => $auth_encryption_key;
|
||||
'DEFAULT/heat_stack_user_role' : value => $heat_stack_user_role;
|
||||
'DEFAULT/heat_metadata_server_url' : value => $heat_metadata_server_url;
|
||||
'DEFAULT/heat_waitcondition_server_url': value => $heat_waitcondition_server_url;
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'heat::engine' do
|
||||
|
||||
let :default_params do
|
||||
{ :enabled => true,
|
||||
:heat_stack_user_role => 'heat_stack_user',
|
||||
:heat_metadata_server_url => 'http://127.0.0.1:8000',
|
||||
:heat_waitcondition_server_url => 'http://127.0.0.1:8000/v1/waitcondition',
|
||||
:heat_watch_server_url => 'http://128.0.0.1:8003',
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'heat-engine' do
|
||||
[
|
||||
{},
|
||||
{ :auth_encryption_key => '1234567890AZERTYUIOPMLKJHGFDSQ' },
|
||||
{ :auth_encryption_key => 'foodummybar',
|
||||
:enabled => false,
|
||||
:heat_stack_user_role => 'heat_stack_user',
|
||||
:heat_metadata_server_url => 'http://127.0.0.1:8000',
|
||||
:heat_waitcondition_server_url => 'http://127.0.0.1:8000/v1/waitcondition',
|
||||
:heat_watch_server_url => 'http://128.0.0.1:8003',
|
||||
}
|
||||
].each do |new_params|
|
||||
describe 'when #{param_set == {} ? "using default" : "specifying"} parameters'
|
||||
|
||||
let :params do
|
||||
new_params
|
||||
end
|
||||
|
||||
let :expected_params do
|
||||
default_params.merge(params)
|
||||
end
|
||||
|
||||
it { should contain_package('heat-engine').with_name(os_params[:package_name]) }
|
||||
|
||||
it { should contain_service('heat-engine').with(
|
||||
:ensure => expected_params[:enabled] ? 'running' : 'stopped',
|
||||
:name => os_params[:service_name],
|
||||
:enable => expected_params[:enabled],
|
||||
:hasstatus => 'true',
|
||||
:hasrestart => 'true',
|
||||
:require => [ 'File[/etc/heat/heat.conf]',
|
||||
'Package[heat-common]',
|
||||
'Package[heat-engine]'],
|
||||
:subscribe => 'Exec[heat-dbsync]'
|
||||
) }
|
||||
|
||||
it { should contain_heat_config('DEFAULT/auth_encryption_key').with_value( expected_params[:auth_encryption_key] ) }
|
||||
it { should contain_heat_config('DEFAULT/heat_stack_user_role').with_value( expected_params[:heat_stack_user_role] ) }
|
||||
it { should contain_heat_config('DEFAULT/heat_metadata_server_url').with_value( expected_params[:heat_metadata_server_url] ) }
|
||||
it { should contain_heat_config('DEFAULT/heat_waitcondition_server_url').with_value( expected_params[:heat_waitcondition_server_url] ) }
|
||||
it { should contain_heat_config('DEFAULT/heat_watch_server_url').with_value( expected_params[:heat_watch_server_url] ) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
|
||||
let :os_params do
|
||||
{ :package_name => 'heat-engine',
|
||||
:service_name => 'heat-engine'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'heat-engine'
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
let :os_params do
|
||||
{ :package_name => 'openstack-heat-engine',
|
||||
:service_name => 'openstack-heat-engine'
|
||||
}
|
||||
end
|
||||
|
||||
it_configures 'heat-engine'
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue