Clean up `mysql::database'

refs #6842
This commit is contained in:
Alexander Klimov 2014-08-28 14:16:21 +02:00
parent 5c0f998085
commit 5f977328a9
2 changed files with 4 additions and 6 deletions

View File

@ -7,7 +7,7 @@ class icinga2-mysql {
password => 'icinga2',
privileges => 'SELECT,INSERT,UPDATE,DELETE',
schemafile => '/usr/share/icinga2-ido-mysql/schema/mysql.sql',
requirement => Package['icinga2-ido-mysql'],
require => Package['icinga2-ido-mysql'],
}
icinga2::feature { 'ido-mysql':

View File

@ -6,13 +6,11 @@ define mysql::database::create ($username, $password, $privileges) {
command => "mysql -uroot -e \"CREATE DATABASE ${name}; \
GRANT ${privileges} ON ${name}.* TO ${username}@localhost \
IDENTIFIED BY '${password}';\"",
require => Service['mysqld']
require => Class['mysql']
}
}
define mysql::database::populate ($username, $password, $privileges, $schemafile, $requirement) {
include mysql
define mysql::database::populate ($username, $password, $privileges, $schemafile) {
mysql::database::create { $name:
username => $username,
password => $password,
@ -22,6 +20,6 @@ define mysql::database::populate ($username, $password, $privileges, $schemafile
exec { "populate-${name}-mysql-db":
unless => "mysql -u${username} -p${password} ${name} -e \"SELECT * FROM icinga_dbversion;\" &> /dev/null",
command => "mysql -uroot ${name} < ${schemafile}",
require => [ $requirement, Exec["create-mysql-${name}-db"] ]
require => Mysql::Database::Create[$name],
}
}