Adding tacker::server and updating the RedHat service name

Change-Id: I2e86c4855fbad7b3a00e731c94df4457fc3b2913
This commit is contained in:
Dan Radez 2017-01-27 09:40:42 -05:00
parent 2dddc6be36
commit 11e2863ea0
3 changed files with 134 additions and 1 deletions

View File

@ -7,7 +7,7 @@ class tacker::params {
case $::osfamily {
'RedHat': {
$package_name = 'openstack-tacker'
$service_name = 'tacker-server'
$service_name = 'openstack-tacker-server'
}
'Debian': {
$package_name = 'tacker'

63
manifests/server.pp Normal file
View File

@ -0,0 +1,63 @@
# = Class: tacker::server
#
# This class manages the Tacker server.
#
# [*enabled*]
# (Optional) Service enable state for tacker-server.
# Defaults to true.
#
# [*manage_service*]
# (Optional) Whether the service is managed by this puppet class.
# Defaults to true.
#
# [*auth_strategy*]
# (optional) Type of authentication to be used.
# Defaults to 'keystone'
#
# [*bind_host*]
# (optional) The host IP to bind to.
# Defaults to $::os_service_default
#
# [*bind_port*]
# (optional) The port to bind to.
# Defaults to $::os_service_default
#
class tacker::server(
$manage_service = true,
$enabled = true,
$auth_strategy = 'keystone',
$bind_host = $::os_service_default,
$bind_port = $::os_service_default,
) {
include ::tacker::deps
include ::tacker::params
include ::tacker::policy
if $auth_strategy == 'keystone' {
include ::tacker::keystone::authtoken
}
tacker_config {
'DEFAULT/bind_host' : value => $bind_host;
'DEFAULT/bind_port' : value => $bind_port;
}
if $manage_service {
if $enabled {
$service_ensure = 'running'
} else {
$service_ensure = 'stopped'
}
}
if $manage_service {
service { 'tacker-server':
ensure => $service_ensure,
name => $::tacker::params::service_name,
enable => $enabled,
tag => 'tacker-service'
}
}
}

View File

@ -0,0 +1,70 @@
require 'spec_helper'
describe 'tacker::server' do
let :pre_condition do
"class { '::tacker::keystone::authtoken':
password =>'foo',
}
class {'::tacker': }"
end
let :params do
{ :enabled => true,
:manage_service => true,
:bind_host => '0.0.0.0',
:bind_port => '1789'
}
end
shared_examples_for 'tacker::server' do
it { is_expected.to contain_class('tacker::deps') }
it { is_expected.to contain_class('tacker::params') }
it { is_expected.to contain_class('tacker::policy') }
it 'configures api' do
is_expected.to contain_tacker_config('DEFAULT/bind_host').with_value( params[:bind_host] )
is_expected.to contain_tacker_config('DEFAULT/bind_port').with_value( params[:bind_port] )
end
[{:enabled => true}, {:enabled => false}].each do |param_hash|
context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
before do
params.merge!(param_hash)
end
it 'configures tacker-server service' do
is_expected.to contain_service('tacker-server').with(
:ensure => (params[:manage_service] && params[:enabled]) ? 'running' : 'stopped',
:name => platform_params[:tacker_service],
:enable => params[:enabled],
:tag => 'tacker-service',
)
end
end
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
let(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :tacker_service => 'tacker' }
when 'RedHat'
{ :tacker_service => 'openstack-tacker-server' }
end
end
it_configures 'tacker::server'
end
end
end