Avoid conflicting management of zaqar.conf

The zaqar::server_instance resource type allows setting up multiple
instances of zaqar-server by creating /etc/zaqar/{name}.conf .
Currently there is no validation about the name and if it can be set to
'zaqar' which results in conflicting management of zaqar.conf .

This change introduces a simple validation logic to make sure that
the resource type uses a config file different from the base
zaqar.conf .

Change-Id: Idb0eaff24e84121e0c78daf659d5b9f861491faa
This commit is contained in:
Takashi Kajinami 2021-11-01 09:51:43 +09:00
parent b2f53f9dfd
commit 0e7c4f0efe
2 changed files with 32 additions and 18 deletions

View File

@ -16,6 +16,10 @@ define zaqar::server_instance(
$enabled = true, $enabled = true,
) { ) {
if $name == 'zaqar' {
fail('The name should not be \'zaqar\'. Please use a different name')
}
include zaqar include zaqar
include zaqar::deps include zaqar::deps
include zaqar::params include zaqar::params

View File

@ -2,7 +2,10 @@ require 'spec_helper'
describe 'zaqar::server_instance' do describe 'zaqar::server_instance' do
shared_examples_for 'zaqar::server_instance' do shared_examples_for 'zaqar::server_instance' do
let(:title) { '1' } describe 'zaqar::server_instance' do
let :title do
'1'
end
let :pre_condition do let :pre_condition do
"class { 'zaqar::keystone::authtoken': "class { 'zaqar::keystone::authtoken':
@ -17,14 +20,21 @@ describe 'zaqar::server_instance' do
} }
end end
describe 'with a websocket server instance 1' do context 'with a websocket server instance 1' do
it { is_expected.to contain_service("#{platform_params[:zaqar_service_name]}@1").with( it { is_expected.to contain_service("#{platform_params[:zaqar_service_name]}@1").with(
:ensure => 'running', :ensure => 'running',
:enable => true :enable => true
)} )}
it { is_expected.to contain_file('/etc/zaqar/1.conf') } it { is_expected.to contain_file('/etc/zaqar/1.conf') }
end
context 'with the name not allowed' do
let :title do
'zaqar'
end
it { is_expected.to raise_error(Puppet::Error) }
end
end end
end end