]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/openstacklib/manifests/db/mysql.pp
7cf10102989db6849b4aa24fa99bee47e42529e0
[dsa-puppet.git] / 3rdparty / modules / openstacklib / manifests / db / mysql.pp
1 # == Definition: openstacklib::db::mysql
2 #
3 # This resource configures a mysql database for an OpenStack service
4 #
5 # == Parameters:
6 #
7 #  [*password_hash*]
8 #    Password hash to use for the database user for this service;
9 #    string; required
10 #
11 #  [*dbname*]
12 #    The name of the database
13 #    string; optional; default to the $title of the resource, i.e. 'nova'
14 #
15 #  [*user*]
16 #    The database user to create;
17 #    string; optional; default to the $title of the resource, i.e. 'nova'
18 #
19 #  [*host*]
20 #    The IP address or hostname of the user in mysql_grant;
21 #    string; optional; default to '127.0.0.1'
22 #
23 #  [*charset*]
24 #    The charset to use for the database;
25 #    string; optional; default to 'utf8'
26 #
27 #  [*collate*]
28 #    The collate to use for the database;
29 #    string; optional; default to 'utf8_general_ci'
30 #
31 #  [*allowed_hosts*]
32 #    Additional hosts that are allowed to access this database;
33 #    array or string; optional; default to undef
34 #
35 #  [*privileges*]
36 #    Privileges given to the database user;
37 #    string or array of strings; optional; default to 'ALL'
38
39 define openstacklib::db::mysql (
40   $password_hash,
41   $dbname         = $title,
42   $user           = $title,
43   $host           = '127.0.0.1',
44   $charset        = 'utf8',
45   $collate        = 'utf8_general_ci',
46   $allowed_hosts  = [],
47   $privileges     = 'ALL',
48 ) {
49
50   include ::mysql::client
51
52   mysql_database { $dbname:
53     ensure  => present,
54     charset => $charset,
55     collate => $collate,
56     require => [ Class['mysql::server'], Class['mysql::client'] ],
57   }
58
59   $allowed_hosts_list = unique(concat(any2array($allowed_hosts), [$host]))
60   $real_allowed_hosts = prefix($allowed_hosts_list, "${dbname}_")
61
62   openstacklib::db::mysql::host_access { $real_allowed_hosts:
63     user          => $user,
64     password_hash => $password_hash,
65     database      => $dbname,
66     privileges    => $privileges,
67   }
68 }