Update containers to CentOS Stream 8
[barometer.git] / puppet-barometer / manifests / db / mysql.pp
1 # The barometer::db::mysql class implements mysql backend for barometer
2 #
3 # This class can be used to create tables, users and grant
4 # privilege for a mysql barometer database.
5 #
6 # == parameters
7 #
8 # [*password*]
9 #   (Mandatory) Password to connect to the database.
10 #   Defaults to 'false'.
11 #
12 # [*dbname*]
13 #   (Optional) Name of the database.
14 #   Defaults to 'barometer'.
15 #
16 # [*user*]
17 #   (Optional) User to connect to the database.
18 #   Defaults to 'barometer'.
19 #
20 # [*host*]
21 #   (Optional) The default source host user is allowed to connect from.
22 #   Defaults to '127.0.0.1'
23 #
24 # [*allowed_hosts*]
25 #   (Optional) Other hosts the user is allowed to connect from.
26 #   Defaults to 'undef'.
27 #
28 # [*charset*]
29 #   (Optional) The database charset.
30 #   Defaults to 'utf8'
31 #
32 # [*collate*]
33 #   (Optional) The database collate.
34 #   Only used with mysql modules >= 2.2.
35 #   Defaults to 'utf8_general_ci'
36 #
37 # == Dependencies
38 #   Class['mysql::server']
39 #
40 # == Examples
41 #
42 # == Authors
43 #
44 # == Copyright
45 #
46 class barometer::db::mysql(
47   $password,
48   $dbname        = 'barometer',
49   $user          = 'barometer',
50   $host          = '127.0.0.1',
51   $charset       = 'utf8',
52   $collate       = 'utf8_general_ci',
53   $allowed_hosts = undef
54 ) {
55
56   validate_string($password)
57
58   ::openstacklib::db::mysql { 'barometer':
59     user          => $user,
60     password_hash => mysql_password($password),
61     dbname        => $dbname,
62     host          => $host,
63     charset       => $charset,
64     collate       => $collate,
65     allowed_hosts => $allowed_hosts,
66   }
67
68   ::Openstacklib::Db::Mysql['barometer'] ~> Exec<| title == 'barometer-manage db_sync' |>
69 }