]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/openstacklib/manifests/db/mysql/host_access.pp
try again, with puppetforge modules, correctly included now
[dsa-puppet.git] / 3rdparty / modules / openstacklib / manifests / db / mysql / host_access.pp
1 # Allow a user to access the database for the service
2 #
3 # == Namevar
4 #  String with the form dbname_host. The host part of the string is the host
5 #  to allow
6 #
7 # == Parameters
8 #  [*user*]
9 #    username to allow
10 #
11 #  [*password_hash*]
12 #    user password hash
13 #
14 #  [*database*]
15 #    the database name
16 #
17 #  [*privileges*]
18 #    the privileges to grant to this user
19 #
20 define openstacklib::db::mysql::host_access (
21   $user,
22   $password_hash,
23   $database,
24   $privileges,
25 ) {
26   validate_re($title, '_', 'Title must be $dbname_$host')
27
28   $host = inline_template('<%= @title.split("_").last %>')
29
30   mysql_user { "${user}@${host}":
31     password_hash => $password_hash,
32     require       => Mysql_database[$database],
33   }
34
35   mysql_grant { "${user}@${host}/${database}.*":
36     privileges => $privileges,
37     table      => "${database}.*",
38     require    => Mysql_user["${user}@${host}"],
39     user       => "${user}@${host}",
40   }
41 }