module-mysql/manifests/admin_user.pp

24 lines
568 B
ObjectPascal
Raw Normal View History

2012-12-09 15:52:34 +01:00
# add an admin user that has
# access to all databases
2011-10-27 23:28:10 +02:00
define mysql::admin_user(
2012-12-09 15:52:34 +01:00
$password,
2011-10-27 23:28:10 +02:00
$ensure = present,
2012-12-09 15:52:34 +01:00
$host = '127.0.0.1'
2011-10-27 23:28:10 +02:00
){
2012-12-09 15:52:34 +01:00
$password_hash = $password ? {
'trocla' => trocla("mysql_admin-user_${name}",'mysql'),
default => $password,
}
2011-10-27 23:28:10 +02:00
mysql_user{"${name}@${host}":
2012-12-09 15:52:34 +01:00
ensure => $ensure,
password_hash => $password_hash,
require => Exec['mysql_set_rootpw'],
2011-10-27 23:28:10 +02:00
}
if $ensure == 'present' {
mysql_grant{"${name}@${host}":
privileges => 'all',
require => Mysql_user["${name}@${host}"],
}
2011-10-27 23:28:10 +02:00
}
}