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:
parent
7708359f04
commit
dd5fb3ea91
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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}"]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue