Files
puppet-nova/manifests/db/mysql.pp
Michael Chapman d08a38be60 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
2014-03-22 02:14:05 +11:00

100 lines
2.5 KiB
Puppet

# == Class: nova::db::mysql
#
# Class that configures mysql for nova
#
# === Parameters:
#
# [*password*]
# Password to use for the nova user
#
# [*dbname*]
# (optional) The name of the database
# Defaults to 'nova'
#
# [*user*]
# (optional) The mysql user to create
# Defaults to 'nova'
#
# [*host*]
# (optional) The IP address of the mysql server
# Defaults to '127.0.0.1'
#
# [*charset*]
# (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
#
# [*cluster_id*]
# (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
) {
if $cluster_id {
warning('The cluster_id parameter is deprecated and has no effect.')
}
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' |>
# 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)
} elsif is_string($allowed_hosts) and ($allowed_hosts != $host) {
$real_allowed_hosts = $allowed_hosts
}
if $real_allowed_hosts {
nova::db::mysql::host_access { $real_allowed_hosts:
user => $user,
password => $password,
database => $dbname,
mysql_module => $mysql_module,
}
}
}