Add support for puppetlabs-mysql 2.2
This patch adds support for the new version of puppetlabs-mysql via a parameter that will change which types and classes to depend on from the mysql module. No spec tests are included since any tests relying on the new module will fail until the fixtures are updated. Change-Id: I3f76cc600ef8d6e0c88c988f96aadbf18d81f7f1
This commit is contained in:
parent
18f6a9d164
commit
addaf5179d
5
README
5
README
@ -2,6 +2,11 @@ puppet-ceilometer
|
||||
|
||||
This is the ceilometer module.
|
||||
|
||||
Limitations
|
||||
--------------------------
|
||||
|
||||
The Ceilometer Openstack service depends on a sqlalchemy database. If you are using puppetlabs-mysql to achieve this, there is a parameter called mysql_module that can be used to swap between the two supported versions: 0.9 and 2.2. This is needed because the puppetlabs-mysql module was rewritten and the custom type names have changed between versions.
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
|
@ -9,9 +9,15 @@
|
||||
# [*sync_db*]
|
||||
# enable dbsync.
|
||||
#
|
||||
# [*mysql_module*]
|
||||
# (optional) Mysql puppet module version to use. Tested versions
|
||||
# are 0.9 and 2.2
|
||||
# Defaults to '0.9
|
||||
#
|
||||
class ceilometer::db (
|
||||
$database_connection = 'mysql://ceilometer:ceilometer@localhost/ceilometer',
|
||||
$sync_db = true
|
||||
$sync_db = true,
|
||||
$mysql_module = '0.9',
|
||||
) {
|
||||
|
||||
include ceilometer::params
|
||||
@ -24,8 +30,13 @@ class ceilometer::db (
|
||||
case $database_connection {
|
||||
/^mysql:\/\//: {
|
||||
$backend_package = false
|
||||
|
||||
if ($mysql_module >= 2.2) {
|
||||
include mysql::bindings::python
|
||||
} else {
|
||||
include mysql::python
|
||||
}
|
||||
}
|
||||
/^postgres:\/\//: {
|
||||
$backend_package = $::ceilometer::params::psycopg_package_name
|
||||
}
|
||||
|
@ -23,6 +23,14 @@
|
||||
# [*charset*]
|
||||
# the database charset. Optional. Defaults to 'latin1'
|
||||
#
|
||||
# [*collate*]
|
||||
# the database collation. Optional. Defaults to 'latin1_swedish_ci'
|
||||
#
|
||||
# [*mysql_module*]
|
||||
# (optional) Mysql module version to use. Tested versions
|
||||
# are 0.9 and 2.2
|
||||
# Defaults to '0.9'
|
||||
#
|
||||
class ceilometer::db::mysql(
|
||||
$password = false,
|
||||
$dbname = 'ceilometer',
|
||||
@ -30,6 +38,8 @@ class ceilometer::db::mysql(
|
||||
$host = 'localhost',
|
||||
$allowed_hosts = undef,
|
||||
$charset = 'latin1',
|
||||
$collate = 'latin1_swedish_ci',
|
||||
$mysql_module = '0.9',
|
||||
) {
|
||||
|
||||
validate_string($password)
|
||||
@ -38,6 +48,16 @@ class ceilometer::db::mysql(
|
||||
Class['ceilometer::db::mysql'] -> Exec<| title == 'ceilometer-dbsync' |>
|
||||
Mysql::Db[$dbname] ~> Exec<| title == 'ceilometer-dbsync' |>
|
||||
|
||||
if $mysql_module >= 2.2 {
|
||||
mysql::db { $dbname:
|
||||
user => $user,
|
||||
password => $password,
|
||||
host => $host,
|
||||
charset => $charset,
|
||||
collate => $collate,
|
||||
require => Class['mysql::server'],
|
||||
}
|
||||
} else {
|
||||
mysql::db { $dbname:
|
||||
user => $user,
|
||||
password => $password,
|
||||
@ -45,6 +65,7 @@ class ceilometer::db::mysql(
|
||||
charset => $charset,
|
||||
require => Class['mysql::config'],
|
||||
}
|
||||
}
|
||||
|
||||
# Check allowed_hosts to avoid duplicate resource declarations
|
||||
if is_array($allowed_hosts) and delete($allowed_hosts,$host) != [] {
|
||||
@ -58,6 +79,7 @@ class ceilometer::db::mysql(
|
||||
user => $user,
|
||||
password => $password,
|
||||
database => $dbname,
|
||||
mysql_module => $mysql_module,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,22 @@
|
||||
# [*database*]
|
||||
# the database name
|
||||
#
|
||||
define ceilometer::db::mysql::host_access ($user, $password, $database) {
|
||||
define ceilometer::db::mysql::host_access ($user, $password, $database, $mysql_module='0.9') {
|
||||
# New types for mysql module v2.0+
|
||||
if ($mysql_module >= 2.2) {
|
||||
mysql_user { "${user}@${name}":
|
||||
password_hash => mysql_password($password),
|
||||
provider => 'mysql',
|
||||
require => Mysql_database[$database],
|
||||
}
|
||||
|
||||
mysql_grant { "${user}@${name}/${database}":
|
||||
privileges => 'all',
|
||||
provider => 'mysql',
|
||||
require => Mysql_user["${user}@${name}"]
|
||||
}
|
||||
|
||||
} else {
|
||||
database_user { "${user}@${name}":
|
||||
password_hash => mysql_password($password),
|
||||
provider => 'mysql',
|
||||
@ -28,3 +42,4 @@ define ceilometer::db::mysql::host_access ($user, $password, $database) {
|
||||
require => Database_user["${user}@${name}"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,9 @@ describe 'ceilometer::db::mysql' do
|
||||
:dbname => 'ceilometer',
|
||||
:user => 'ceilometer',
|
||||
:host => 'localhost',
|
||||
:charset => 'latin1'
|
||||
:charset => 'latin1',
|
||||
:collate => 'latin1_swedish_ci',
|
||||
:mysql_module => '0.9',
|
||||
}
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user