Files
puppet-nova/manifests/db/mysql.pp
Xingchao Yu e8cebd12f3 Update allowed_hosts conditional statement
In the origin nova::db::mysql, if the value of $allowed_hosts
contains or equals to $host, then puppet will complain duplicate
declaration error. This patch is aim to update the allowed_hosts
conditonal statement in nova::db::mysql.

There are two cases to pass $allowed_hosts to $real_allowed_hosts:

   - If $allowed_hosts is array,then remove $host from $allowed_hosts;
   - elsif $allowed_hosts is string and not equivalent to $host;

At last, if $real_allowed_hosts is not undef, then run
nova::db::mysql::host_access

Fix bug 1206444
Change-Id: If018321095e62e1196e0c2e6b623b30acb535020
2013-08-01 14:37:46 +08:00

42 lines
1.1 KiB
Puppet

#
# Class that configures mysql for nova
#
class nova::db::mysql(
$password,
$dbname = 'nova',
$user = 'nova',
$host = '127.0.0.1',
$charset = 'latin1',
$allowed_hosts = undef,
$cluster_id = 'localzone'
) {
require 'mysql::python'
# 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)
} 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,
}
}
}