Add support for puppetlabs-mysql 2.2
Puppetlabs-mysql has been rewritten to be much cleaner. This patch adds a new parameter for the nova mysql and init classes allowing users to use the new version. Previous behavior will continue as normal when using the old version (0.9) Change-Id: I6d12a69180554348143f7f341f7570c52ecad140
This commit is contained in:
@@ -72,6 +72,7 @@ Limitations
|
||||
|
||||
* Supports libvirt, xenserver and vmware compute drivers.
|
||||
* Tested on EL and Debian derivatives.
|
||||
* The Nova 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.
|
||||
|
||||
Development
|
||||
-----------
|
||||
|
@@ -20,9 +20,13 @@
|
||||
# Defaults to '127.0.0.1'
|
||||
#
|
||||
# [*charset*]
|
||||
# (optional) The chaset to use for the nova database
|
||||
# (optional) The charset to use for the nova database
|
||||
# Defaults to 'latin1'
|
||||
#
|
||||
# [*collate*]
|
||||
# (optional) The collate to use for the nova database
|
||||
# Defaults to 'latin1_swedish_ci'
|
||||
#
|
||||
# [*allowed_hosts*]
|
||||
# (optional) Additional hosts that are allowed to access this DB
|
||||
# Defaults to undef
|
||||
@@ -31,13 +35,20 @@
|
||||
# (optional) Deprecated. Does nothing
|
||||
# Defaults to 'localzone'
|
||||
#
|
||||
# [*mysql_module*]
|
||||
# (optional) Mysql puppet module version to use. Tested versions
|
||||
# are 0.9 and 2.2.
|
||||
# Defaults to '0.9'
|
||||
#
|
||||
class nova::db::mysql(
|
||||
$password,
|
||||
$dbname = 'nova',
|
||||
$user = 'nova',
|
||||
$host = '127.0.0.1',
|
||||
$charset = 'latin1',
|
||||
$collate = 'latin1_swedish_ci',
|
||||
$allowed_hosts = undef,
|
||||
$mysql_module = '0.9',
|
||||
$cluster_id = undef
|
||||
) {
|
||||
|
||||
@@ -45,19 +56,31 @@ class nova::db::mysql(
|
||||
warning('The cluster_id parameter is deprecated and has no effect.')
|
||||
}
|
||||
|
||||
require 'mysql::python'
|
||||
if ($mysql_module >= 2.2) {
|
||||
mysql::db { $dbname:
|
||||
user => $user,
|
||||
password => $password,
|
||||
host => $host,
|
||||
charset => $charset,
|
||||
collate => $collate,
|
||||
require => Class['mysql::server'],
|
||||
}
|
||||
} else {
|
||||
require 'mysql::python'
|
||||
|
||||
mysql::db { $dbname:
|
||||
user => $user,
|
||||
password => $password,
|
||||
host => $host,
|
||||
charset => $charset,
|
||||
require => Class['mysql::config'],
|
||||
}
|
||||
}
|
||||
|
||||
# Create the db instance before openstack-nova if its installed
|
||||
Mysql::Db[$dbname] -> Anchor<| title == 'nova-start' |>
|
||||
Mysql::Db[$dbname] ~> Exec<| title == 'nova-db-sync' |>
|
||||
|
||||
mysql::db { $dbname:
|
||||
user => $user,
|
||||
password => $password,
|
||||
host => $host,
|
||||
charset => $charset,
|
||||
require => Class['mysql::config'],
|
||||
}
|
||||
|
||||
# Check allowed_hosts to avoid duplicate resource declarations
|
||||
if is_array($allowed_hosts) and delete($allowed_hosts,$host) != [] {
|
||||
$real_allowed_hosts = delete($allowed_hosts,$host)
|
||||
@@ -67,9 +90,10 @@ class nova::db::mysql(
|
||||
|
||||
if $real_allowed_hosts {
|
||||
nova::db::mysql::host_access { $real_allowed_hosts:
|
||||
user => $user,
|
||||
password => $password,
|
||||
database => $dbname,
|
||||
user => $user,
|
||||
password => $password,
|
||||
database => $dbname,
|
||||
mysql_module => $mysql_module,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,29 @@
|
||||
# db/allowed_hosts.pp
|
||||
define nova::db::mysql::host_access ($user, $password, $database) {
|
||||
database_user { "${user}@${name}":
|
||||
password_hash => mysql_password($password),
|
||||
provider => 'mysql',
|
||||
require => Database[$database],
|
||||
}
|
||||
database_grant { "${user}@${name}/${database}":
|
||||
# TODO figure out which privileges to grant.
|
||||
privileges => 'all',
|
||||
provider => 'mysql',
|
||||
require => Database_user["${user}@${name}"]
|
||||
define nova::db::mysql::host_access ($user, $password, $database, $mysql_module = '0.9') {
|
||||
if ($mysql_module >= 2.2) {
|
||||
mysql_user { "${user}@${name}":
|
||||
password_hash => mysql_password($password),
|
||||
require => Mysql_database[$database],
|
||||
}
|
||||
|
||||
mysql_grant { "${user}@${name}/${database}.*":
|
||||
privileges => ['ALL'],
|
||||
options => ['GRANT'],
|
||||
table => "${database}.*",
|
||||
require => Mysql_user["${user}@${name}"],
|
||||
user => "${user}@${name}"
|
||||
}
|
||||
} else {
|
||||
database_user { "${user}@${name}":
|
||||
password_hash => mysql_password($password),
|
||||
provider => 'mysql',
|
||||
require => Database[$database],
|
||||
}
|
||||
database_grant { "${user}@${name}/${database}":
|
||||
# TODO figure out which privileges to grant.
|
||||
privileges => 'all',
|
||||
provider => 'mysql',
|
||||
require => Database_user["${user}@${name}"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -167,6 +167,11 @@
|
||||
# the ownership of all files/dirs owned by nova.
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*mysql_module*]
|
||||
# (optional) Mysql module version to use. Tested versions
|
||||
# are 0.9 and 2.2
|
||||
# Defaults to '0.9'
|
||||
#
|
||||
class nova(
|
||||
$ensure_package = 'present',
|
||||
$database_connection = false,
|
||||
@@ -210,6 +215,7 @@ class nova(
|
||||
$use_syslog = false,
|
||||
$log_facility = 'LOG_USER',
|
||||
$install_utilities = true,
|
||||
$mysql_module = '0.9',
|
||||
# DEPRECATED PARAMETERS
|
||||
# this is how to query all resources from our clutser
|
||||
$nova_cluster_id = undef,
|
||||
@@ -311,7 +317,12 @@ class nova(
|
||||
# that may need to be collected from a remote host
|
||||
if $database_connection_real {
|
||||
if($database_connection_real =~ /mysql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
require 'mysql::python'
|
||||
if ($mysql_module >= 2.2) {
|
||||
require 'mysql::bindings'
|
||||
require 'mysql::bindings::python'
|
||||
} else {
|
||||
require 'mysql::python'
|
||||
}
|
||||
} elsif($database_connection_real =~ /postgresql:\/\/\S+:\S+@\S+\/\S+/) {
|
||||
|
||||
} elsif($database_connection_real =~ /sqlite:\/\//) {
|
||||
|
Reference in New Issue
Block a user