Defined Type: nuodb::manager::database

Defined in:
manifests/manager/database.pp

Overview

Define: nuodb::manager::database

This type allows creating and deleting a database.

Examples:

class { '::nuodb' :
  databases => {
    'testdb1' => {
      ensure       => present,
      template     => 'Minimally Redundant',
      dba_username => 'dba1',
      dba_password => 'pwd1',
    },
  },
}
::nuodb::manager::database { 'testdb1':
  ensure       => present,
  template     => 'Minimally Redundant',
  dba_username => 'dba1',
  dba_password => 'pwd1',
}

Parameters:

  • ensure (Any) (defaults to: 'present')

    the ensure value to determine if the database should be present or absent. Defaults to present.

  • nuodb_home (Any) (defaults to: $::nuodb::nuodb_home)

    the directory where NuoDB is installed to. Defaults to the install location from the module.

  • broker_host (Any) (defaults to: $::nuodb::default_properties['altAddr'])

    the host name for the broker instance to connect to create the database. Defaults to the ‘altAddr’ property set for the default.properties in the module parameters.

  • domain_password (Any) (defaults to: $::nuodb::default_properties['domainPassword'])

    domain password to use for authenticating with the broker. Defaults to the ‘domainPassword’ property set for the default.properties in the module parameters.

  • database_name (Any) (defaults to: $title)

    name of the database to create. Defaults to the title.

  • template (Any) (defaults to: 'Single Host')

    the database template to use, must be one of ‘Single Host’, ‘Minimally Redundant’, ‘Multi Host’ or ‘Region distributed’. Defaults to ‘Single Host’.

  • dba_username (Any) (defaults to: 'dbaUser')

    Database administrator username for the database. Defaults to the title.

  • dba_password (Any) (defaults to: 'dbaPassword')

    Database administrator password for the database. Defaults to the title.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'manifests/manager/database.pp', line 37

define nuodb::manager::database (
  $ensure          = 'present',
  $nuodb_home      = $::nuodb::nuodb_home,
  $broker_host     = $::nuodb::default_properties['altAddr'],
  $domain_password = $::nuodb::default_properties['domainPassword'],
  $database_name   = $title,
  $template        = 'Single Host',
  $dba_username    = 'dbaUser',
  $dba_password    = 'dbaPassword',
) {

  validate_re($ensure, '^(present|absent)$')
  validate_re($template, '^(Single Host|Minimally Redundant|Multi Host|Region distributed)$')

  $base_command = "${nuodb_home}/bin/nuodbmgr --broker '${broker_host}' --password '${domain_password}' --command"
  $exists_check = "${base_command} \"show domain databases\" | grep -q -e \"^${database_name} \\[\""

  if ($ensure == 'present') {
    $extra_params = "template '${template}' dbaUser '${dba_username}' dbaPassword '${dba_password}'"

    exec { "create-database-${database_name}" :
      command => "${base_command} \"create database dbname '${database_name}' ${extra_params}\"",
      unless  => $exists_check,
    }
  } else {
    exec { "shutdown-database-${database_name}" :
      command => "${base_command} \"shutdown database '${database_name}'\"",
      onlyif  => $exists_check,
    } ->
    exec { "delete-database-${database_name}" :
      command => "${base_command} \"delete database '${database_name}'\"",
      onlyif  => $exists_check,
    }
  }
}