summaryrefslogtreecommitdiffstats
path: root/puppet-barometer/manifests/db
diff options
context:
space:
mode:
Diffstat (limited to 'puppet-barometer/manifests/db')
-rw-r--r--puppet-barometer/manifests/db/mysql.pp69
-rw-r--r--puppet-barometer/manifests/db/postgresql.pp55
-rw-r--r--puppet-barometer/manifests/db/sync.pp26
3 files changed, 150 insertions, 0 deletions
diff --git a/puppet-barometer/manifests/db/mysql.pp b/puppet-barometer/manifests/db/mysql.pp
new file mode 100644
index 00000000..c9284082
--- /dev/null
+++ b/puppet-barometer/manifests/db/mysql.pp
@@ -0,0 +1,69 @@
+# The barometer::db::mysql class implements mysql backend for barometer
+#
+# This class can be used to create tables, users and grant
+# privilege for a mysql barometer database.
+#
+# == parameters
+#
+# [*password*]
+# (Mandatory) Password to connect to the database.
+# Defaults to 'false'.
+#
+# [*dbname*]
+# (Optional) Name of the database.
+# Defaults to 'barometer'.
+#
+# [*user*]
+# (Optional) User to connect to the database.
+# Defaults to 'barometer'.
+#
+# [*host*]
+# (Optional) The default source host user is allowed to connect from.
+# Defaults to '127.0.0.1'
+#
+# [*allowed_hosts*]
+# (Optional) Other hosts the user is allowed to connect from.
+# Defaults to 'undef'.
+#
+# [*charset*]
+# (Optional) The database charset.
+# Defaults to 'utf8'
+#
+# [*collate*]
+# (Optional) The database collate.
+# Only used with mysql modules >= 2.2.
+# Defaults to 'utf8_general_ci'
+#
+# == Dependencies
+# Class['mysql::server']
+#
+# == Examples
+#
+# == Authors
+#
+# == Copyright
+#
+class barometer::db::mysql(
+ $password,
+ $dbname = 'barometer',
+ $user = 'barometer',
+ $host = '127.0.0.1',
+ $charset = 'utf8',
+ $collate = 'utf8_general_ci',
+ $allowed_hosts = undef
+) {
+
+ validate_string($password)
+
+ ::openstacklib::db::mysql { 'barometer':
+ user => $user,
+ password_hash => mysql_password($password),
+ dbname => $dbname,
+ host => $host,
+ charset => $charset,
+ collate => $collate,
+ allowed_hosts => $allowed_hosts,
+ }
+
+ ::Openstacklib::Db::Mysql['barometer'] ~> Exec<| title == 'barometer-manage db_sync' |>
+}
diff --git a/puppet-barometer/manifests/db/postgresql.pp b/puppet-barometer/manifests/db/postgresql.pp
new file mode 100644
index 00000000..35d9b58b
--- /dev/null
+++ b/puppet-barometer/manifests/db/postgresql.pp
@@ -0,0 +1,55 @@
+# == Class: barometer::db::postgresql
+#
+# Class that configures postgresql for barometer
+# Requires the Puppetlabs postgresql module.
+#
+# === Parameters
+#
+# [*password*]
+# (Required) Password to connect to the database.
+#
+# [*dbname*]
+# (Optional) Name of the database.
+# Defaults to 'barometer'.
+#
+# [*user*]
+# (Optional) User to connect to the database.
+# Defaults to 'barometer'.
+#
+# [*encoding*]
+# (Optional) The charset to use for the database.
+# Default to undef.
+#
+# [*privileges*]
+# (Optional) Privileges given to the database user.
+# Default to 'ALL'
+#
+# == Dependencies
+#
+# == Examples
+#
+# == Authors
+#
+# == Copyright
+#
+class barometer::db::postgresql(
+ $password,
+ $dbname = 'barometer',
+ $user = 'barometer',
+ $encoding = undef,
+ $privileges = 'ALL',
+) {
+
+ Class['barometer::db::postgresql'] -> Service<| title == 'barometer' |>
+
+ ::openstacklib::db::postgresql { 'barometer':
+ password_hash => postgresql_password($user, $password),
+ dbname => $dbname,
+ user => $user,
+ encoding => $encoding,
+ privileges => $privileges,
+ }
+
+ ::Openstacklib::Db::Postgresql['barometer'] ~> Exec<| title == 'barometer-manage db_sync' |>
+
+}
diff --git a/puppet-barometer/manifests/db/sync.pp b/puppet-barometer/manifests/db/sync.pp
new file mode 100644
index 00000000..6a67bf2f
--- /dev/null
+++ b/puppet-barometer/manifests/db/sync.pp
@@ -0,0 +1,26 @@
+#
+# Class to execute barometer-manage db_sync
+#
+# == Parameters
+#
+# [*extra_params*]
+# (optional) String of extra command line parameters to append
+# to the barometer-dbsync command.
+# Defaults to undef
+#
+class barometer::db::sync(
+ $extra_params = undef,
+) {
+ exec { 'barometer-db-sync':
+ command => "barometer-manage db_sync ${extra_params}",
+ path => [ '/bin', '/usr/bin', ],
+ user => 'barometer',
+ refreshonly => true,
+ try_sleep => 5,
+ tries => 10,
+ logoutput => on_failure,
+ subscribe => [Package['barometer'], Barometer_config['database/connection']],
+ }
+
+ Exec['barometer-manage db_sync'] ~> Service<| title == 'barometer' |>
+}