Ensure python-redis is install

The python-redis package is an optional dependency and needs to be
installed explicitly in Ubuntu or Debian. (The zaqar package in RDO
has additonal dependency to require python-redis now).

Change-Id: I5c768a4ed60909f2e764ed6a39c372814b50c58b
This commit is contained in:
Takashi Kajinami 2024-04-08 15:53:11 +09:00
parent d3fe8601ba
commit 0cc6468f2b
6 changed files with 112 additions and 26 deletions

View File

@ -1,25 +1,36 @@
# == class: zaqar::management::redis
#
# [*uri*]
# Redis connection URI. Required.
# (Required) Redis Connection URI.
#
# [*max_reconnect_attempts*]
# Maximum number of times to retry an operation that failed due to a redis
# node failover.
# Defaults to $facts['os_service_default']
# (Optional) Maximum number of times to retry an operation that failed due to
# a primary node failover.
# Defaults to $facts['os_service_default'].
#
# [*reconnect_sleep*]
# Base sleep interval between attempts to reconnect after a redis node
# failover.
# Defaults to $facts['os_service_default']
# (Optional) Base sleep interval between attempts to reconnect after
# a primary node failover.
# Defaults to $facts['os_service_default'].
#
# [*package_ensure*]
# (Optional) Ensure state for package.
# Defaults to 'present'
#
# [*manage_package*]
# (Optional) Manage pyhton-redis package.
# Defaults to true
#
class zaqar::management::redis(
$uri,
$max_reconnect_attempts = $facts['os_service_default'],
$reconnect_sleep = $facts['os_service_default'],
$package_ensure = 'present',
Boolean $manage_package = true,
) {
include zaqar::deps
include zaqar::params
zaqar_config {
'drivers:management_store:redis/uri': value => $uri, secret => true;
@ -27,4 +38,15 @@ class zaqar::management::redis(
'drivers:management_store:redis/reconnect_sleep': value => $reconnect_sleep;
}
if $manage_package {
ensure_packages('python-redis', {
name => $::zaqar::params::python_redis_package_name,
ensure => $package_ensure,
tag => ['openstack'],
})
Anchor['zaqar::install::begin']
-> Package<| name == $::oslo::params::python_redis_package_name |>
-> Anchor['zaqar::install::end']
}
}

View File

@ -1,26 +1,36 @@
# == class: zaqar::messaging::redis
#
# [*uri*]
# Redis Connection URI. Required.
# (Required) Redis Connection URI.
#
# [*max_reconnect_attempts*]
# Maximum number of times to retry an operation that failed due to a
# primary node failover. (integer value)
# (Optional) Maximum number of times to retry an operation that failed due to
# a primary node failover.
# Defaults to $facts['os_service_default'].
#
# [*reconnect_sleep*]
# Base sleep interval between attempts to reconnect after a primary
# node failover. The actual sleep time increases exponentially (power
# of 2) each time the operation is retried. (floating point value)
# (Optional) Base sleep interval between attempts to reconnect after
# a primary node failover.
# Defaults to $facts['os_service_default'].
#
# [*package_ensure*]
# (Optional) Ensure state for package.
# Defaults to 'present'
#
# [*manage_package*]
# (Optional) Manage pyhton-redis package.
# Defaults to true
#
class zaqar::messaging::redis(
$uri,
$max_reconnect_attempts = $facts['os_service_default'],
$reconnect_sleep = $facts['os_service_default'],
$package_ensure = 'present',
Boolean $manage_package = true,
) {
include zaqar::deps
include zaqar::params
zaqar_config {
'drivers:message_store:redis/uri': value => $uri, secret => true;
@ -28,4 +38,15 @@ class zaqar::messaging::redis(
'drivers:message_store:redis/reconnect_sleep': value => $reconnect_sleep;
}
if $manage_package {
ensure_packages('python-redis', {
name => $::zaqar::params::python_redis_package_name,
ensure => $package_ensure,
tag => ['openstack'],
})
Anchor['zaqar::install::begin']
-> Package<| name == $::oslo::params::python_redis_package_name |>
-> Anchor['zaqar::install::end']
}
}

View File

@ -13,16 +13,18 @@ class zaqar::params {
case $facts['os']['family'] {
'RedHat': {
$package_name = 'openstack-zaqar'
$service_name = 'openstack-zaqar'
$zaqar_wsgi_script_source = "/usr/lib/python${pyver3}/site-packages/zaqar/transport/wsgi/app.py"
$zaqar_wsgi_script_path = '/var/www/cgi-bin/zaqar'
$package_name = 'openstack-zaqar'
$service_name = 'openstack-zaqar'
$zaqar_wsgi_script_source = "/usr/lib/python${pyver3}/site-packages/zaqar/transport/wsgi/app.py"
$zaqar_wsgi_script_path = '/var/www/cgi-bin/zaqar'
$python_redis_package_name = 'python3-redis'
}
'Debian': {
$package_name = 'zaqar-server'
$service_name = 'zaqar-server'
$zaqar_wsgi_script_source = '/usr/lib/python3/dist-packages/zaqar/transport/wsgi/app.py'
$zaqar_wsgi_script_path = '/usr/lib/cgi-bin/zaqar'
$package_name = 'zaqar-server'
$service_name = 'zaqar-server'
$zaqar_wsgi_script_source = '/usr/lib/python3/dist-packages/zaqar/transport/wsgi/app.py'
$zaqar_wsgi_script_path = '/usr/lib/cgi-bin/zaqar'
$python_redis_package_name = 'python3-redis'
}
default: {
fail("Unsupported osfamily: ${facts['os']['family']}")

View File

@ -0,0 +1,8 @@
---
features:
- |
The ``zaqar::messaging::redis`` class and the ``zaqar::management::redis``
class now ensures that the python3-redis package is installed.
The new ``package_ensure`` parameter can be used to customize state of
the package. To disable the package management, use the ``manage_package``
parameter.

View File

@ -31,6 +31,11 @@ describe 'zaqar::management::redis' do
is_expected.to contain_zaqar_config('drivers:management_store:redis/uri').with_value('redis://127.0.0.1:6379')
is_expected.to contain_zaqar_config('drivers:management_store:redis/max_reconnect_attempts').with_value('<SERVICE DEFAULT>')
is_expected.to contain_zaqar_config('drivers:management_store:redis/reconnect_sleep').with_value('<SERVICE DEFAULT>')
is_expected.to contain_package('python-redis').with(
:ensure => 'installed',
:name => platform_params[:python_redis_package_name],
:tag => ['openstack'],
)
end
end
@ -58,6 +63,19 @@ describe 'zaqar::management::redis' do
facts.merge!(OSDefaults.get_facts())
end
let(:platform_params) do
case facts[:os]['family']
when 'Debian'
{
:python_redis_package_name => 'python3-redis',
}
when 'RedHat'
{
:python_redis_package_name => 'python3-redis',
}
end
end
it_configures 'zaqar::management::redis'
end
end

View File

@ -27,11 +27,13 @@ describe 'zaqar::messaging::redis' do
end
it 'should config redis messaging driver' do
is_expected.to contain_zaqar_config('drivers/message_store').with(
:value => 'redis'
)
is_expected.to contain_zaqar_config('drivers:message_store:redis/uri').with(
:value => 'redis://127.0.0.1:6379'
is_expected.to contain_zaqar_config('drivers/message_store').with_value('redis')
is_expected.to contain_zaqar_config('drivers:message_store:redis/uri').with_value('redis://127.0.0.1:6379')
is_expected.to contain_zaqar_config('drivers:message_store:redis/reconnect_sleep').with_value('<SERVICE DEFAULT>')
is_expected.to contain_package('python-redis').with(
:ensure => 'installed',
:name => platform_params[:python_redis_package_name],
:tag => ['openstack'],
)
end
@ -60,6 +62,19 @@ describe 'zaqar::messaging::redis' do
facts.merge!(OSDefaults.get_facts())
end
let(:platform_params) do
case facts[:os]['family']
when 'Debian'
{
:python_redis_package_name => 'python3-redis',
}
when 'RedHat'
{
:python_redis_package_name => 'python3-redis',
}
end
end
it_configures 'zaqar::messaging::redis'
end
end