Add ability to disable backend packages management
There are use cases where an user wants to not have backend packages automatically installed. One use case would be the user having an alternative set of packages already providing backend packages as built-in dependencies. Installing system packages is redundant, useless and causing confusion. This change adds the ability to disable backend packages management while preserving previous behavior which consists of installing them automatically. Closes-bug: #1715204 Change-Id: Ief676d4c5aaa81f4547dd2e090dfcc8c62855148
This commit is contained in:
parent
6ff575f6c0
commit
5911b080b3
@ -113,6 +113,10 @@
|
|||||||
# client connection. (integer value)
|
# client connection. (integer value)
|
||||||
# Defaults to $::os_service_default
|
# Defaults to $::os_service_default
|
||||||
#
|
#
|
||||||
|
# [*manage_backend_package*]
|
||||||
|
# (Optional) Whether to install the backend package.
|
||||||
|
# Defaults to true.
|
||||||
|
#
|
||||||
define oslo::cache(
|
define oslo::cache(
|
||||||
$config_prefix = $::os_service_default,
|
$config_prefix = $::os_service_default,
|
||||||
$expiration_time = $::os_service_default,
|
$expiration_time = $::os_service_default,
|
||||||
@ -127,6 +131,7 @@ define oslo::cache(
|
|||||||
$memcache_pool_maxsize = $::os_service_default,
|
$memcache_pool_maxsize = $::os_service_default,
|
||||||
$memcache_pool_unused_timeout = $::os_service_default,
|
$memcache_pool_unused_timeout = $::os_service_default,
|
||||||
$memcache_pool_connection_get_timeout = $::os_service_default,
|
$memcache_pool_connection_get_timeout = $::os_service_default,
|
||||||
|
$manage_backend_package = true,
|
||||||
){
|
){
|
||||||
|
|
||||||
include ::oslo::params
|
include ::oslo::params
|
||||||
@ -149,17 +154,19 @@ define oslo::cache(
|
|||||||
$proxies_orig = $proxies
|
$proxies_orig = $proxies
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($backend =~ /pylibmc/ ) {
|
if $manage_backend_package {
|
||||||
ensure_packages('python-pylibmc', {
|
if ($backend =~ /pylibmc/ ) {
|
||||||
ensure => present,
|
ensure_packages('python-pylibmc', {
|
||||||
name => $::oslo::params::pylibmc_package_name,
|
ensure => present,
|
||||||
tag => 'openstack',
|
name => $::oslo::params::pylibmc_package_name,
|
||||||
})
|
tag => 'openstack',
|
||||||
} elsif ($backend =~ /\.memcache/ ) {
|
})
|
||||||
ensure_resources('package', { 'python-memcache' => {
|
} elsif ($backend =~ /\.memcache/ ) {
|
||||||
name => $::oslo::params::python_memcache_package_name,
|
ensure_resources('package', { 'python-memcache' => {
|
||||||
tag => ['openstack'],
|
name => $::oslo::params::python_memcache_package_name,
|
||||||
}})
|
tag => ['openstack'],
|
||||||
|
}})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$cache_options = {
|
$cache_options = {
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
# (Optional) The back end to use for the database.
|
# (Optional) The back end to use for the database.
|
||||||
# Defaults to $::os_service_default
|
# Defaults to $::os_service_default
|
||||||
#
|
#
|
||||||
|
# [*manage_backend_package*]
|
||||||
|
# (Optional) Whether to install the backend package.
|
||||||
|
# Defaults to true.
|
||||||
|
#
|
||||||
# [*backend_package_ensure*]
|
# [*backend_package_ensure*]
|
||||||
# (Optional) Desired ensure state of the backend database package,
|
# (Optional) Desired ensure state of the backend database package,
|
||||||
# accepts latest or specific versions.
|
# accepts latest or specific versions.
|
||||||
@ -105,6 +109,7 @@
|
|||||||
define oslo::db(
|
define oslo::db(
|
||||||
$sqlite_synchronous = $::os_service_default,
|
$sqlite_synchronous = $::os_service_default,
|
||||||
$backend = $::os_service_default,
|
$backend = $::os_service_default,
|
||||||
|
$manage_backend_package = true,
|
||||||
$backend_package_ensure = present,
|
$backend_package_ensure = present,
|
||||||
$connection = $::os_service_default,
|
$connection = $::os_service_default,
|
||||||
$slave_connection = $::os_service_default,
|
$slave_connection = $::os_service_default,
|
||||||
@ -135,36 +140,38 @@ define oslo::db(
|
|||||||
validate_re($connection,
|
validate_re($connection,
|
||||||
'^(sqlite|mysql(\+pymysql)?|postgresql|mongodb):\/\/(\S+:\S+@\S+\/\S+)?')
|
'^(sqlite|mysql(\+pymysql)?|postgresql|mongodb):\/\/(\S+:\S+@\S+\/\S+)?')
|
||||||
|
|
||||||
case $connection {
|
if $manage_backend_package {
|
||||||
/^mysql(\+pymysql)?:\/\//: {
|
case $connection {
|
||||||
require '::mysql::bindings'
|
/^mysql(\+pymysql)?:\/\//: {
|
||||||
require '::mysql::bindings::python'
|
require '::mysql::bindings'
|
||||||
if $connection =~ /^mysql\+pymysql/ {
|
require '::mysql::bindings::python'
|
||||||
$backend_package = $::oslo::params::pymysql_package_name
|
if $connection =~ /^mysql\+pymysql/ {
|
||||||
} else {
|
$backend_package = $::oslo::params::pymysql_package_name
|
||||||
|
} else {
|
||||||
|
$backend_package = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/^postgresql:\/\//: {
|
||||||
$backend_package = false
|
$backend_package = false
|
||||||
|
require '::postgresql::lib::python'
|
||||||
|
}
|
||||||
|
/^mongodb:\/\//: {
|
||||||
|
$backend_package = $::oslo::params::pymongo_package_name
|
||||||
|
}
|
||||||
|
/^sqlite:\/\//: {
|
||||||
|
$backend_package = $::oslo::params::sqlite_package_name
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
fail('Unsupported backend configured')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/^postgresql:\/\//: {
|
|
||||||
$backend_package = false
|
|
||||||
require '::postgresql::lib::python'
|
|
||||||
}
|
|
||||||
/^mongodb:\/\//: {
|
|
||||||
$backend_package = $::oslo::params::pymongo_package_name
|
|
||||||
}
|
|
||||||
/^sqlite:\/\//: {
|
|
||||||
$backend_package = $::oslo::params::sqlite_package_name
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
fail('Unsupported backend configured')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if $backend_package and !defined(Package[$backend_package]) {
|
if $backend_package and !defined(Package[$backend_package]) {
|
||||||
package { $backend_package:
|
package { $backend_package:
|
||||||
ensure => $backend_package_ensure,
|
ensure => $backend_package_ensure,
|
||||||
name => $backend_package,
|
name => $backend_package,
|
||||||
tag => 'openstack',
|
tag => 'openstack',
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,18 @@ describe 'oslo::cache' do
|
|||||||
:tag => 'openstack',
|
:tag => 'openstack',
|
||||||
)
|
)
|
||||||
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.not_to contain_package('python-pylibmc')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with memcache backend' do
|
context 'with memcache backend' do
|
||||||
@ -91,6 +103,18 @@ describe 'oslo::cache' do
|
|||||||
:tag => ['openstack'],
|
:tag => ['openstack'],
|
||||||
)
|
)
|
||||||
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.not_to contain_package('python-memcache')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with string in list parameters' do
|
context 'with string in list parameters' do
|
||||||
|
@ -89,6 +89,18 @@ describe 'oslo::db' do
|
|||||||
:tag => 'openstack'
|
:tag => 'openstack'
|
||||||
)
|
)
|
||||||
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.not_to contain_package('python-pymongo')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with specific mongodb connection string' do
|
context 'with specific mongodb connection string' do
|
||||||
@ -117,6 +129,18 @@ describe 'oslo::db' do
|
|||||||
it 'install the proper backend package' do
|
it 'install the proper backend package' do
|
||||||
is_expected.to contain_package('python-psycopg2').with(:ensure => 'present')
|
is_expected.to contain_package('python-psycopg2').with(:ensure => 'present')
|
||||||
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.not_to contain_package('python-psycopg2')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with incorrect database_connection string' do
|
context 'with incorrect database_connection string' do
|
||||||
@ -149,6 +173,18 @@ describe 'oslo::db' do
|
|||||||
:tag => 'openstack'
|
:tag => 'openstack'
|
||||||
)
|
)
|
||||||
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.not_to contain_package('python-pymysql')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with sqlite backend' do
|
context 'with sqlite backend' do
|
||||||
@ -163,6 +199,18 @@ describe 'oslo::db' do
|
|||||||
:tag => 'openstack'
|
:tag => 'openstack'
|
||||||
)
|
)
|
||||||
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.not_to contain_package('python-pysqlite2')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user