Add code for db and host_access

Glance can be configured to use a mysql db.

This commit adds the classes db and db/host_access.
This commit is contained in:
Dan Bode 2012-03-29 16:43:23 -07:00
parent 7708359f04
commit dd5fb3ea91
2 changed files with 41 additions and 0 deletions

27
manifests/db.pp Normal file
View File

@ -0,0 +1,27 @@
class glance::db(
$password,
$dbname = 'glance',
$user = 'glance',
$host = '127.0.0.1',
$allowed_hosts = undef,
$cluster_id = 'localzone'
) {
mysql::db { $dbname:
user => $user,
password => $password,
host => $host,
charset => 'latin1',
# I may want to inject some sql
require => Class['mysql::server'],
}
if $allowed_hosts {
# TODO this class should be in the mysql namespace
glance::db::host_access { $allowed_hosts:
user => $user,
password => $password,
database => $dbname,
}
}
}

View File

@ -0,0 +1,14 @@
# db/allowed_hosts.pp
define glance::db::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}"]
}
}