Puppet Class: icinga::web::vspheredb

Defined in:
manifests/web/vspheredb.pp

Summary

Setup VSphereDB module for Icinga Web 2

Overview

Parameters:

  • service_ensure (Stdlib::Ensure::Service) (defaults to: 'running')

    Manages if the VSphereDB service should be stopped or running.

  • service_enable (Boolean) (defaults to: true)

    If set to true the VSphereDB service will start on boot.

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

    Type of your database. At the moment only ‘mysql` is supported by the Icinga team.

  • db_host (Stdlib::Host) (defaults to: 'localhost')

    Hostname of the database.

  • db_port (Optional[Stdlib::Port]) (defaults to: undef)

    Port of the database.

  • db_name (String) (defaults to: 'vspheredb')

    Name of the database.

  • db_user (String) (defaults to: 'vspheredb')

    Username for DB connection.

  • db_pass (Icinga::Secret)

    Password for DB connection.

  • manage_database (Boolean) (defaults to: false)

    Create database and import schema.



31
32
33
34
35
36
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'manifests/web/vspheredb.pp', line 31

class icinga::web::vspheredb (
  Icinga::Secret            $db_pass,
  Stdlib::Ensure::Service   $service_ensure  = 'running',
  Boolean                   $service_enable  = true,
  Enum['mysql']             $db_type         = 'mysql',
  Stdlib::Host              $db_host         = 'localhost',
  Optional[Stdlib::Port]    $db_port         = undef,
  String                    $db_name         = 'vspheredb',
  String                    $db_user         = 'vspheredb',
  Boolean                   $manage_database = false,
) {
  icinga::prepare_web('VSphereDB')

  $icingaweb2_version = $icinga::web::icingaweb2_version
  $_db_charset        = $db_type ? {
    'mysql' => 'utf8mb4',
    default => 'UTF8',
  }

  #
  # Database
  #
  if $manage_database {
    class { 'icinga::web::vspheredb::database':
      db_type       => $db_type,
      db_name       => $db_name,
      db_user       => $db_user,
      db_pass       => $db_pass,
      web_instances => ['localhost'],
      before        => Class['icingaweb2::module::vspheredb'],
    }
    $_db_host = 'localhost'
  } else {
    if $db_type != 'pgsql' {
      include mysql::client
    } else {
      include postgresql::client
    }
    $_db_host = $db_host
  }

  class { 'icingaweb2::module::vspheredb':
    install_method => 'package',
    db_type        => $db_type,
    db_host        => $_db_host,
    db_port        => $db_port,
    db_name        => $db_name,
    db_username    => $db_user,
    db_password    => $db_pass,
    db_charset     => $_db_charset,
    import_schema  => lookup('icingaweb2::module::vspheredb::import_schema', undef, undef, true),
  }

  if versioncmp($icingaweb2_version, '4.0.0') < 0 {
    service { 'icinga-vspheredb':
      ensure  => $service_ensure,
      enable  => $service_enable,
      require => Class['icingaweb2::module::vspheredb'],
    }
  }
}