coordination: Make status of the backend package configurable

... as is implemented in other resources like oslo::cache.

Change-Id: I459b7b752a83f75b1cb05c2104812133039a9162
This commit is contained in:
Takashi Kajinami 2021-08-29 11:42:34 +09:00
parent b05244e2a1
commit e4e0d3e391
4 changed files with 102 additions and 25 deletions

View File

@ -8,6 +8,10 @@
# (Optional) Coordination backend URL.
# Defaults to $::os_service_default
#
# [*manage_backend_package*]
# (Optional) Whether to install the backend package.
# Defaults to true.
#
# [*package_ensure*]
# (Optional) ensure state for package.
# Defaults to 'present'
@ -17,14 +21,15 @@
# Defaults to true.
#
define oslo::coordination (
$backend_url = $::os_service_default,
$package_ensure = 'present',
$manage_config = true,
$backend_url = $::os_service_default,
$manage_backend_package = true,
$package_ensure = 'present',
$manage_config = true,
) {
include oslo::params
if !is_service_default($backend_url) {
if $manage_backend_package and !is_service_default($backend_url){
case $backend_url {
/^redis:\/\//: {
ensure_packages('python-redis', {

View File

@ -0,0 +1,5 @@
---
features:
- |
The ``oslo::coordination::manage_backend_package`` parameter has been
added.

View File

@ -90,18 +90,6 @@ describe 'oslo::cache' do
:tag => 'openstack',
)
end
context 'with backend package management disabled' do
before do
params.merge!({
:manage_backend_package => false,
})
end
it 'does not install backend package' do
is_expected.not_to contain_package('python-pylibmc')
end
end
end
context 'with memcache backend' do
@ -118,17 +106,36 @@ describe 'oslo::cache' do
:tag => ['openstack'],
)
end
end
context 'with backend package management disabled' do
before do
params.merge!({
:manage_backend_package => false,
})
end
context 'with backend package management disabled' do
before do
params.merge!({
:backend => 'dogpile.cache.pylibmc',
:manage_backend_package => false,
})
end
it 'does not install backend package' do
is_expected.not_to contain_package('python-memcache')
end
it 'does not install backend package' do
is_expected.to contain_keystone_config('cache/backend').with_value('dogpile.cache.pylibmc')
is_expected.to_not contain_package('python-pylibmc')
end
end
context 'with package_ensure set' do
before do
params.merge!({
:backend => 'dogpile.cache.pylibmc',
:package_ensure => 'present',
})
end
it 'ensures status of the backend package' do
is_expected.to contain_package('python-pylibmc').with(
:ensure => 'latest',
:name => platform_params[:pylibmc_package_name],
:tag => 'openstack',
)
end
end

View File

@ -26,6 +26,18 @@ describe 'oslo::coordination' do
:tag => 'openstack',
)
end
context 'with backend package management disabled' do
before do
params.merge!({
:manage_backend_package => false,
})
end
it 'does not install backend package' do
is_expected.to_not contain_package('python-redis')
end
end
end
context 'with etcd3 backend' do
@ -46,6 +58,18 @@ describe 'oslo::coordination' do
is_expected.to_not contain_package('python-etcd3')
end
end
context 'with backend package management disabled' do
before do
params.merge!({
:manage_backend_package => false,
})
end
it 'does not install backend package' do
is_expected.to_not contain_package('python-etcd3')
end
end
end
context 'with etcd3gw backend(http)' do
@ -57,6 +81,18 @@ describe 'oslo::coordination' do
is_expected.to contain_keystone_config('coordination/backend_url').with_value('etcd3+http://localhost:2379')
is_expected.to contain_package('python-etcd3gw')
end
context 'with backend package management disabled' do
before do
params.merge!({
:manage_backend_package => false,
})
end
it 'does not install backend package' do
is_expected.to_not contain_package('python-etcd3gw')
end
end
end
context 'with etcd3gw backend(https)' do
@ -68,6 +104,18 @@ describe 'oslo::coordination' do
is_expected.to contain_keystone_config('coordination/backend_url').with_value('etcd3+https://localhost:2379')
is_expected.to contain_package('python-etcd3gw')
end
context 'with backend package management disabled' do
before do
params.merge!({
:manage_backend_package => false,
})
end
it 'does not install backend package' do
is_expected.to_not contain_package('python-etcd3gw')
end
end
end
context 'with memcache backend' do
@ -84,6 +132,18 @@ describe 'oslo::coordination' do
:tag => 'openstack',
)
end
context 'with backend package management disabled' do
before do
params.merge!({
:manage_backend_package => false,
})
end
it 'does not install backend package' do
is_expected.to_not contain_package('python-pymemcache')
end
end
end
context 'with configuration management disabled' do