Add general basic functionality to the base barbican class

This is the prep work to migrate some common parameters from the api
class to the base class, and implements basic functionality so that
the base class provides consistent functionality in all modules.

Change-Id: I0e20b135e8c29f1d27d39d2940d49ea30a1f512c
This commit is contained in:
Takashi Kajinami 2022-04-26 01:05:36 +09:00
parent 7558739921
commit 700b5e4148
4 changed files with 86 additions and 2 deletions

View File

@ -1,9 +1,33 @@
# == Class: barbican
#
# Full description of class barbican here.
# Barbican base package & configuration
#
class barbican {
# === Parameters
#
# [*package_ensure*]
# (Optional) Ensure state for package.
# Defaults to 'present'.
#
# [*purge_config*]
# (optional) Whether to set only the specified config options
# in the cinder config.
# Defaults to false.
#
class barbican(
$package_ensure = 'present',
$purge_config = false,
) {
include barbican::deps
include barbican::params
package { 'barbican':
ensure => $package_ensure,
name => $::barbican::params::common_package_name,
tag => ['openstack', 'barbican-package'],
}
resources { 'barbican_config':
purge => $purge_config,
}
}

View File

@ -12,6 +12,7 @@ class barbican::params {
case $::osfamily {
'RedHat': {
$common_package_name = 'openstack-barbican-common'
$api_package_name = 'openstack-barbican-api'
$api_service_name = 'openstack-barbican-api'
$worker_package_name = 'openstack-barbican-worker'
@ -22,6 +23,7 @@ class barbican::params {
$barbican_wsgi_script_source = '/usr/bin/barbican-wsgi-api'
}
'Debian': {
$common_package_name = 'barbican-common'
$api_service_name = 'barbican-api'
$api_package_name = 'barbican-api'
$worker_package_name = 'barbican-worker'

View File

@ -0,0 +1,9 @@
---
features:
- |
The ``barbican`` class now installs the ``barbican-common`` package. Status
of the package can be customized by the ``barbican::package_ensure``
parameter.
- |
The ``barbican::purge_config`` parameter has been added.

View File

@ -0,0 +1,49 @@
require 'spec_helper'
describe 'barbican' do
shared_examples 'barbican' do
it { is_expected.to contain_class('barbican::deps') }
context 'with default parameters' do
let :params do
{}
end
it 'installs packages' do
is_expected.to contain_package('barbican').with(
:name => platform_params[:barbican_common_package],
:ensure => 'present',
:tag => ['openstack', 'barbican-package']
)
end
it 'passes purge to resource' do
is_expected.to contain_resources('barbican_config').with({
:purge => false
})
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'
{ :barbican_common_package => 'barbican-common' }
when 'RedHat'
{ :barbican_common_package => 'openstack-barbican-common' }
end
end
it_behaves_like 'barbican'
end
end
end