Make privileges customizable in mysql::database::create (and mysql::database::populate)

refs #6842
This commit is contained in:
Alexander Klimov 2014-08-05 16:12:47 +02:00
parent 920a784beb
commit 2e1afd7194
2 changed files with 6 additions and 3 deletions

View File

@ -15,6 +15,7 @@ $casperjsVersion = '1.0.2'
mysql::database::populate { 'icinga':
username => 'icinga',
password => 'icinga',
privileges => 'SELECT,INSERT,UPDATE,DELETE',
schemafile => "/usr/local/src/icinga-mysql/icinga-${icingaVersion}/module/idoutils/db/mysql/mysql.sql",
requirement => Cmmi['icinga-mysql'],
}
@ -22,6 +23,7 @@ mysql::database::populate { 'icinga':
mysql::database::populate { 'icinga2':
username => 'icinga2',
password => 'icinga2',
privileges => 'SELECT,INSERT,UPDATE,DELETE',
schemafile => "/usr/share/doc/icinga2-ido-mysql-${icinga2Version}/schema/mysql.sql",
requirement => Package['icinga2-ido-mysql'],
}

View File

@ -1,21 +1,22 @@
define mysql::database::create ($username, $password) {
define mysql::database::create ($username, $password, $privileges) {
include mysql
exec { "create-mysql-${name}-db":
unless => "mysql -u${username} -p${password} ${name}",
command => "mysql -uroot -e \"CREATE DATABASE ${name}; \
GRANT SELECT,INSERT,UPDATE,DELETE ON ${name}.* TO ${username}@localhost \
GRANT ${privileges} ON ${name}.* TO ${username}@localhost \
IDENTIFIED BY '${password}';\"",
require => Service['mysqld']
}
}
define mysql::database::populate ($username, $password, $schemafile, $requirement) {
define mysql::database::populate ($username, $password, $privileges, $schemafile, $requirement) {
include mysql
mysql::database::create { $name:
username => $username,
password => $password,
privileges => $privileges,
}
exec { "populate-${name}-mysql-db":