Add support for puppetlabs-mysql 2.2
Puppetlabs-mysql has been rewritten to be much cleaner. This patch adds a new parameter for the heat 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: I4d268d793740c31493acd5999dd3f8501cc1d281
This commit is contained in:
parent
82a4f8a109
commit
074675b1ac
|
@ -37,6 +37,8 @@ puppet-heat is a combination of Puppet manifest and ruby code to delivery config
|
|||
Limitations
|
||||
-----------
|
||||
|
||||
The Heat 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
|
||||
-----------
|
||||
|
||||
|
|
|
@ -23,6 +23,16 @@
|
|||
# [*charset*]
|
||||
# the database charset. Optional. Defaults to 'latin1'
|
||||
#
|
||||
# [*collate*]
|
||||
# the database collate. Optional. Only used with mysql modules
|
||||
# >= 2.2
|
||||
# Defaults to 'latin1_swedish_ci'
|
||||
#
|
||||
# [*mysql_module*]
|
||||
# The version of the mysql puppet module to use.
|
||||
# Tested versions include 0.9 and 2.2
|
||||
# Defaults to '0.9'.
|
||||
#
|
||||
class heat::db::mysql(
|
||||
$password = false,
|
||||
$dbname = 'heat',
|
||||
|
@ -30,6 +40,8 @@ class heat::db::mysql(
|
|||
$host = 'localhost',
|
||||
$allowed_hosts = undef,
|
||||
$charset = 'latin1',
|
||||
$collate = 'latin1_swedish_ci',
|
||||
$mysql_module = '0.9'
|
||||
) {
|
||||
|
||||
validate_string($password)
|
||||
|
@ -37,12 +49,23 @@ class heat::db::mysql(
|
|||
Class['heat::db::mysql'] -> Exec<| title == 'heat-manage db_sync' |>
|
||||
Mysql::Db[$dbname] ~> Exec<| title == 'heat-manage db_sync' |>
|
||||
|
||||
mysql::db { $dbname:
|
||||
user => $user,
|
||||
password => $password,
|
||||
host => $host,
|
||||
charset => $charset,
|
||||
require => Class['mysql::config'],
|
||||
if ($mysql_module >= 2.2) {
|
||||
mysql::db { $dbname:
|
||||
user => $user,
|
||||
password => $password,
|
||||
host => $host,
|
||||
charset => $charset,
|
||||
collate => $collate,
|
||||
require => Service['mysql'],
|
||||
}
|
||||
} else {
|
||||
mysql::db { $dbname:
|
||||
user => $user,
|
||||
password => $password,
|
||||
host => $host,
|
||||
charset => $charset,
|
||||
require => Class['mysql::config'],
|
||||
}
|
||||
}
|
||||
|
||||
# Check allowed_hosts to avoid duplicate resource declarations
|
||||
|
@ -54,9 +77,10 @@ class heat::db::mysql(
|
|||
|
||||
if $real_allowed_hosts {
|
||||
heat::db::mysql::host_access { $real_allowed_hosts:
|
||||
user => $user,
|
||||
password => $password,
|
||||
database => $dbname,
|
||||
user => $user,
|
||||
password => $password,
|
||||
database => $dbname,
|
||||
mysql_module => $mysql_module,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,18 +13,31 @@
|
|||
# [*database*]
|
||||
# the database name
|
||||
#
|
||||
define heat::db::mysql::host_access ($user, $password, $database) {
|
||||
define heat::db::mysql::host_access ($user, $password, $database, $mysql_module) {
|
||||
if ($mysql_module >= 2.2) {
|
||||
mysql_user { "${user}@${name}":
|
||||
password_hash => mysql_password($password),
|
||||
require => Mysql_database[$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}"]
|
||||
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}"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,11 @@
|
|||
# (optional) Syslog facility to receive log lines
|
||||
# Defaults to LOG_USER
|
||||
#
|
||||
# [*mysql_module*]
|
||||
# (optional) The mysql puppet module version.
|
||||
# Tested versions include 0.9 and 2.2
|
||||
# Defaults to '0.9'
|
||||
#
|
||||
class heat(
|
||||
$auth_uri = false,
|
||||
$package_ensure = 'present',
|
||||
|
@ -106,6 +111,7 @@ class heat(
|
|||
$database_idle_timeout = 3600,
|
||||
$use_syslog = false,
|
||||
$log_facility = 'LOG_USER',
|
||||
$mysql_module = '0.9',
|
||||
) {
|
||||
|
||||
include heat::params
|
||||
|
@ -234,7 +240,12 @@ class heat(
|
|||
case $sql_connection {
|
||||
/^mysql:\/\//: {
|
||||
$backend_package = false
|
||||
include mysql::python
|
||||
if ($mysql_module >= 2.2) {
|
||||
require mysql::bindings
|
||||
require mysql::bindings::python
|
||||
} else {
|
||||
include mysql::python
|
||||
}
|
||||
}
|
||||
/^postgresql:\/\//: {
|
||||
$backend_package = 'python-psycopg2'
|
||||
|
|
|
@ -6,11 +6,12 @@ describe 'heat::db::mysql' do
|
|||
end
|
||||
|
||||
let :params do
|
||||
{ :password => 's3cr3t',
|
||||
:dbname => 'heat',
|
||||
:user => 'heat',
|
||||
:host => 'localhost',
|
||||
:charset => 'latin1'
|
||||
{ :password => 's3cr3t',
|
||||
:dbname => 'heat',
|
||||
:user => 'heat',
|
||||
:host => 'localhost',
|
||||
:charset => 'latin1',
|
||||
:mysql_module => '0.9'
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -16,7 +16,8 @@ describe 'heat' do
|
|||
:sql_connection => 'mysql://user@host/database',
|
||||
:database_idle_timeout => 3600,
|
||||
:auth_uri => 'http://127.0.0.1:5000/v2.0',
|
||||
:keystone_ec2_uri => 'http://127.0.0.1:5000/v2.0/ec2tokens'
|
||||
:keystone_ec2_uri => 'http://127.0.0.1:5000/v2.0/ec2tokens',
|
||||
:mysql_module => '0.9'
|
||||
}
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue