Files
puppet-gnocchi/manifests/db.pp
Tobias Urdin 12dc2654e8 Use validate_legacy
This changes all the puppet 3 validate_* functions
to use the validate_legacy function.

The validate_legacy function has been available since
about three years but require Puppet >= 4.4.0 and since
there is Puppet 4.10.12 as latest we should assume people
are running a fairly new Puppet 4 version.

This is the first step to then remove all validate function
calls and use proper types for parameter as described in spec [1].

[1] https://review.openstack.org/#/c/568929/

Change-Id: I511f23ac6af3b46bb6f0afc68b41fa1715ba9146
2019-02-23 14:51:43 +01:00

75 lines
2.2 KiB
Puppet

# == Class: gnocchi::db
#
# Configure the Gnocchi database
#
# === Parameters
#
# [*database_connection*]
# Url used to connect to database.
# (Optional) Defaults to 'sqlite:////var/lib/gnocchi/gnocchi.sqlite'.
#
# [*package_ensure*]
# (optional) The state of gnocchi packages
# Defaults to 'present'
#
class gnocchi::db (
$database_connection = 'sqlite:////var/lib/gnocchi/gnocchi.sqlite',
$package_ensure = 'present',
) inherits gnocchi::params {
include ::gnocchi::deps
# NOTE(spredzy): In order to keep backward compatibility we rely on the pick function
# to use gnocchi::<myparam> if gnocchi::db::<myparam> isn't specified.
$database_connection_real = pick($::gnocchi::database_connection, $database_connection)
validate_legacy(Oslo::Dbconn, 'validate_re', $database_connection_real,
['^(sqlite|mysql(\+pymysql)?|postgresql):\/\/(\S+:\S+@\S+\/\S+)?'])
if $database_connection_real {
case $database_connection_real {
/^mysql(\+pymysql)?:\/\//: {
require '::mysql::bindings'
require '::mysql::bindings::python'
if $database_connection_real =~ /^mysql\+pymysql/ {
$backend_package = $::gnocchi::params::pymysql_package_name
} else {
$backend_package = false
}
}
/^postgresql:\/\//: {
$backend_package = false
require '::postgresql::lib::python'
}
/^sqlite:\/\//: {
$backend_package = $::gnocchi::params::sqlite_package_name
}
default: {
fail('Unsupported backend configured')
}
}
if $backend_package and !defined(Package[$backend_package]) {
package {'gnocchi-backend-package':
ensure => present,
name => $backend_package,
tag => 'openstack',
}
}
gnocchi_config {
'indexer/url': value => $database_connection_real, secret => true;
}
# NOTE(tobasco): gnocchi-indexer-sqlalchemy not packaged in Ubuntu for Queens release.
if $::osfamily != 'Debian' {
package { 'gnocchi-indexer-sqlalchemy':
ensure => $package_ensure,
name => $::gnocchi::params::indexer_package_name,
tag => ['openstack', 'gnocchi-package'],
}
}
}
}