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
|
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
|
Development
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,16 @@
|
||||||
# [*charset*]
|
# [*charset*]
|
||||||
# the database charset. Optional. Defaults to 'latin1'
|
# 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(
|
class heat::db::mysql(
|
||||||
$password = false,
|
$password = false,
|
||||||
$dbname = 'heat',
|
$dbname = 'heat',
|
||||||
|
@ -30,6 +40,8 @@ class heat::db::mysql(
|
||||||
$host = 'localhost',
|
$host = 'localhost',
|
||||||
$allowed_hosts = undef,
|
$allowed_hosts = undef,
|
||||||
$charset = 'latin1',
|
$charset = 'latin1',
|
||||||
|
$collate = 'latin1_swedish_ci',
|
||||||
|
$mysql_module = '0.9'
|
||||||
) {
|
) {
|
||||||
|
|
||||||
validate_string($password)
|
validate_string($password)
|
||||||
|
@ -37,12 +49,23 @@ class heat::db::mysql(
|
||||||
Class['heat::db::mysql'] -> Exec<| title == 'heat-manage db_sync' |>
|
Class['heat::db::mysql'] -> Exec<| title == 'heat-manage db_sync' |>
|
||||||
Mysql::Db[$dbname] ~> Exec<| title == 'heat-manage db_sync' |>
|
Mysql::Db[$dbname] ~> Exec<| title == 'heat-manage db_sync' |>
|
||||||
|
|
||||||
mysql::db { $dbname:
|
if ($mysql_module >= 2.2) {
|
||||||
user => $user,
|
mysql::db { $dbname:
|
||||||
password => $password,
|
user => $user,
|
||||||
host => $host,
|
password => $password,
|
||||||
charset => $charset,
|
host => $host,
|
||||||
require => Class['mysql::config'],
|
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
|
# Check allowed_hosts to avoid duplicate resource declarations
|
||||||
|
@ -54,9 +77,10 @@ class heat::db::mysql(
|
||||||
|
|
||||||
if $real_allowed_hosts {
|
if $real_allowed_hosts {
|
||||||
heat::db::mysql::host_access { $real_allowed_hosts:
|
heat::db::mysql::host_access { $real_allowed_hosts:
|
||||||
user => $user,
|
user => $user,
|
||||||
password => $password,
|
password => $password,
|
||||||
database => $dbname,
|
database => $dbname,
|
||||||
|
mysql_module => $mysql_module,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,18 +13,31 @@
|
||||||
# [*database*]
|
# [*database*]
|
||||||
# the database name
|
# 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}":
|
mysql_grant { "${user}@${name}/${database}.*":
|
||||||
password_hash => mysql_password($password),
|
privileges => ['ALL'],
|
||||||
provider => 'mysql',
|
options => ['GRANT'],
|
||||||
require => Database[$database],
|
table => "${database}.*",
|
||||||
}
|
require => Mysql_user["${user}@${name}"],
|
||||||
|
user => "${user}@${name}"
|
||||||
database_grant { "${user}@${name}/${database}":
|
}
|
||||||
# TODO figure out which privileges to grant.
|
} else {
|
||||||
privileges => 'all',
|
database_user { "${user}@${name}":
|
||||||
provider => 'mysql',
|
password_hash => mysql_password($password),
|
||||||
require => Database_user["${user}@${name}"]
|
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
|
# (optional) Syslog facility to receive log lines
|
||||||
# Defaults to LOG_USER
|
# 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(
|
class heat(
|
||||||
$auth_uri = false,
|
$auth_uri = false,
|
||||||
$package_ensure = 'present',
|
$package_ensure = 'present',
|
||||||
|
@ -106,6 +111,7 @@ class heat(
|
||||||
$database_idle_timeout = 3600,
|
$database_idle_timeout = 3600,
|
||||||
$use_syslog = false,
|
$use_syslog = false,
|
||||||
$log_facility = 'LOG_USER',
|
$log_facility = 'LOG_USER',
|
||||||
|
$mysql_module = '0.9',
|
||||||
) {
|
) {
|
||||||
|
|
||||||
include heat::params
|
include heat::params
|
||||||
|
@ -234,7 +240,12 @@ class heat(
|
||||||
case $sql_connection {
|
case $sql_connection {
|
||||||
/^mysql:\/\//: {
|
/^mysql:\/\//: {
|
||||||
$backend_package = false
|
$backend_package = false
|
||||||
include mysql::python
|
if ($mysql_module >= 2.2) {
|
||||||
|
require mysql::bindings
|
||||||
|
require mysql::bindings::python
|
||||||
|
} else {
|
||||||
|
include mysql::python
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/^postgresql:\/\//: {
|
/^postgresql:\/\//: {
|
||||||
$backend_package = 'python-psycopg2'
|
$backend_package = 'python-psycopg2'
|
||||||
|
|
|
@ -6,11 +6,12 @@ describe 'heat::db::mysql' do
|
||||||
end
|
end
|
||||||
|
|
||||||
let :params do
|
let :params do
|
||||||
{ :password => 's3cr3t',
|
{ :password => 's3cr3t',
|
||||||
:dbname => 'heat',
|
:dbname => 'heat',
|
||||||
:user => 'heat',
|
:user => 'heat',
|
||||||
:host => 'localhost',
|
:host => 'localhost',
|
||||||
:charset => 'latin1'
|
:charset => 'latin1',
|
||||||
|
:mysql_module => '0.9'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@ describe 'heat' do
|
||||||
:sql_connection => 'mysql://user@host/database',
|
:sql_connection => 'mysql://user@host/database',
|
||||||
:database_idle_timeout => 3600,
|
:database_idle_timeout => 3600,
|
||||||
:auth_uri => 'http://127.0.0.1:5000/v2.0',
|
: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
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue