Add zaqar::server_instance class.
This class manages N instances of zaqar-server each using an alternate /etc/zaqar/n.conf file to control select service settings which take priority over settings in /etc/zaqar/zaqar.conf. The primary use case for this class would be to enable websockets alongside of wsgi. The only way to do this with Zaqar today is to run multiple processes. Change-Id: Ib730206ece73efe57aca7df4a65c906e95cdd606
This commit is contained in:
parent
ecadc5930d
commit
e9b736c8eb
43
manifests/server_instance.pp
Normal file
43
manifests/server_instance.pp
Normal file
@ -0,0 +1,43 @@
|
||||
# = Class: zaqar::server_instance
|
||||
#
|
||||
# This class manages N instances of zaqar-server each using an
|
||||
# alternate /etc/zaqar/n.conf file to control select service
|
||||
# settings which take priority over settings in /etc/zaqar/zaqar.conf.
|
||||
#
|
||||
# [*transport*]
|
||||
# Set to either 'wsgi' or 'websocket'. Required.
|
||||
#
|
||||
# [*enabled*]
|
||||
# (Optional) Service enable state for zaqar-server.
|
||||
# Defaults to true
|
||||
#
|
||||
define zaqar::server_instance(
|
||||
$transport,
|
||||
$enabled = true,
|
||||
) {
|
||||
|
||||
if $enabled {
|
||||
$service_ensure = 'running'
|
||||
} else {
|
||||
$service_ensure = 'stopped'
|
||||
}
|
||||
|
||||
file { "/etc/zaqar/${name}.conf":
|
||||
ensure => file,
|
||||
content => template('zaqar/zaqar.conf.erb'),
|
||||
}
|
||||
|
||||
include ::zaqar
|
||||
include ::zaqar::params
|
||||
|
||||
service { "openstack-zaqar@${name}":
|
||||
ensure => $service_ensure,
|
||||
enable => $enabled,
|
||||
}
|
||||
|
||||
Package[$::zaqar::params::package_name] ~> Service["${::zaqar::params::service_name}@${name}"]
|
||||
Package[$::zaqar::params::package_name] ~> File["/etc/zaqar/${name}.conf"]
|
||||
File["/etc/zaqar/${name}.conf"] ~> Service["${::zaqar::params::service_name}@${name}"]
|
||||
Zaqar_config<||> ~> Service["${::zaqar::params::service_name}@${name}"]
|
||||
|
||||
}
|
26
spec/classes/zaqar_server_instance_spec.rb
Normal file
26
spec/classes/zaqar_server_instance_spec.rb
Normal file
@ -0,0 +1,26 @@
|
||||
require 'spec_helper'
|
||||
describe 'zaqar' do
|
||||
|
||||
let :pre_condition do
|
||||
"zaqar::server_instance{ '1': transport => 'websocket' }"
|
||||
end
|
||||
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
|
||||
let :params do
|
||||
{ :admin_password => 'foo' }
|
||||
end
|
||||
|
||||
describe 'with a websocket server instance 1' do
|
||||
|
||||
it { is_expected.to contain_service('openstack-zaqar@1').with(
|
||||
:ensure => 'running',
|
||||
:enable => true
|
||||
)}
|
||||
it {is_expected.to contain_file('/etc/zaqar/1.conf') }
|
||||
|
||||
end
|
||||
|
||||
end
|
2
templates/zaqar.conf.erb
Normal file
2
templates/zaqar.conf.erb
Normal file
@ -0,0 +1,2 @@
|
||||
[drivers]
|
||||
transport=<%= @transport %>
|
Loading…
Reference in New Issue
Block a user