Puppet Class: icingaweb2::module::vspheredb

Defined in:
manifests/module/vspheredb.pp

Summary

Installs the vsphereDB plugin

Overview

Examples:

class { 'icingaweb2::module::vspheredb':
  ensure       => 'present',
  git_revision => 'v1.1.0',
  db_host      => 'localhost',
  db_name      => 'vspheredb',
  db_username  => 'vspheredb',
  db_password  => 'supersecret',
}

Parameters:

  • ensure (Enum['absent', 'present']) (defaults to: 'present')

    Ensur es the state of the vspheredb module.

  • module_dir (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Target directory of the module.

  • git_repository (String) (defaults to: 'https://github.com/Icinga/icingaweb2-module-vspheredb.git')

    The upstream module repository.

  • git_revision (Optional[String]) (defaults to: undef)

    The version of the module that needs to be used.

  • install_method (Enum['git', 'none', 'package']) (defaults to: 'git')

    Install methods are ‘git`, `package` and `none` is supported as installation method.

  • package_name (String) (defaults to: 'icingaweb2-module-vspheredb')

    Package name of the module. This setting is only valid in combination with the installation method ‘package`.

  • db_type (Enum['mysql']) (defaults to: 'mysql')

    The database type. Either mysql or postgres.

  • db_host (Optional[Stdlib::Host]) (defaults to: undef)

    The host where the vspheredb-database will be running

  • db_port (Stdlib::Port) (defaults to: 3306)

    The port on which the database is accessible.

  • db_name (Optional[String]) (defaults to: undef)

    The name of the database this module should use.

  • db_username (Optional[String]) (defaults to: undef)

    The username needed to access the database.

  • db_password (Optional[Icingaweb2::Secret]) (defaults to: undef)

    The password needed to access the database.

  • db_charset (String) (defaults to: 'utf8mb4')

    The charset the database is set to.

  • import_schema (Boolean) (defaults to: false)

    Whether to import the database schema or not.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'manifests/module/vspheredb.pp', line 55

class icingaweb2::module::vspheredb (
  Enum['absent', 'present']      $ensure         = 'present',
  Optional[Stdlib::Absolutepath] $module_dir     = undef,
  String                         $git_repository = 'https://github.com/Icinga/icingaweb2-module-vspheredb.git',
  Optional[String]               $git_revision   = undef,
  Enum['git', 'none', 'package'] $install_method = 'git',
  String                         $package_name   = 'icingaweb2-module-vspheredb',
  Enum['mysql']                  $db_type        = 'mysql',
  Optional[Stdlib::Host]         $db_host        = undef,
  Stdlib::Port                   $db_port        = 3306,
  Optional[String]               $db_name        = undef,
  Optional[String]               $db_username    = undef,
  Optional[Icingaweb2::Secret]   $db_password    = undef,
  String                         $db_charset     = 'utf8mb4',
  Boolean                        $import_schema  = false,
) {

  $conf_dir               = $::icingaweb2::globals::conf_dir
  $mysql_vspheredb_schema = $::icingaweb2::globals::mysql_vspheredb_schema
  $module_conf_dir        = "${conf_dir}/modules/vspheredb"

  icingaweb2::config::resource { 'icingaweb2-module-vspheredb':
    type        => 'db',
    db_type     => $db_type,
    host        => $db_host,
    port        => $db_port,
    db_name     => $db_name,
    db_username => $db_username,
    db_password => $db_password,
    db_charset  => $db_charset,
  }

  icingaweb2::module { 'vspheredb':
    ensure         => $ensure,
    git_repository => $git_repository,
    git_revision   => $git_revision,
    install_method => $install_method,
    module_dir     => $module_dir,
    package_name   => $package_name,
    settings       => {
      'icingaweb2-module-vspheredb' => {
        'section_name' => 'db',
        'target'       => "${module_conf_dir}/config.ini",
        'settings'     => {
          'resource' => 'icingaweb2-module-vspheredb',
        },
      },
    },
  }

  if $import_schema {
    $_db_password = icingaweb2::unwrap($db_password)

    case $db_type {
      'mysql': {
        exec { 'import vspheredb schema':
          user    => 'root',
          path    => $::facts['path'],
          command => "mysql -h '${db_host}' -P '${db_port}' -u '${db_username}' -p'${_db_password}' '${db_name}' < '${mysql_vspheredb_schema}'",
          unless  => "mysql -h '${db_host}' -P '${db_port}' -u '${db_username}' -p'${_db_password}' '${db_name}' -Ns -e 'SELECT schema_version FROM vspheredb_schema_migration'",
          require => Icingaweb2::Module['vspheredb'],
        }
      }
      default: {
        fail('The database type you provided is not supported.')
      }
    }
  }

}