Puppet Class: icinga::db

Defined in:
manifests/db.pp

Overview

Parameters:

  • db_type (Enum['mysql', 'pgsql'])

    Choose wether MySQL or PostgreSQL as backend for historical data.

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

    Database server.

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

    Port to connect the database.

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

    The IcingaDB database.

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

    User to connect the database.

  • db_pass (Icinga::Secret)

    Passwort to login into database.

  • manage_database (Boolean) (defaults to: false)

    Install and create database on localhost.

  • db_accesses (Array[Stdlib::Host]) (defaults to: [])

    List of hosts with access to the database, e.g. host running Icinga Web 2. Omly valid if ‘manage_database` is `true`.

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

    Redis host to connect.

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

    When Redis runs on a differnt host than Icinga, here the listining interfaces have to be set.

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

    Port for Redis listening.

  • redis_pass (Optional[Icinga::Secret]) (defaults to: undef)

    Password to authenticate against Redis.

  • manage_redis (Boolean) (defaults to: true)

    Install and create the IcingaDB Redis service on localhost.

  • manage_feature (Boolean) (defaults to: true)

    If you wanna manage the Icinga 2 feature for the IcingaDB, set this to ‘true`. This only make sense when an Icinga 2 Server is running on the same host.



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
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
# File 'manifests/db.pp', line 46

class icinga::db (
  Icinga::Secret                        $db_pass,
  Enum['mysql', 'pgsql']                $db_type,
  Stdlib::Host                          $db_host         = 'localhost',
  Optional[Stdlib::Port::Unprivileged]  $db_port         = undef,
  String                                $db_name         = 'icingadb',
  String                                $db_user         = 'icingadb',
  Boolean                               $manage_database = false,
  Array[Stdlib::Host]                   $db_accesses     = [],
  Stdlib::Host                          $redis_host      = 'localhost',
  Optional[Array[Stdlib::Host]]         $redis_bind      = undef,
  Optional[Stdlib::Port]                $redis_port      = undef,
  Optional[Icinga::Secret]              $redis_pass      = undef,
  Boolean                               $manage_redis    = true,
  Boolean                               $manage_feature  = true,
) {
  if $manage_database {
    $_db_host = 'localhost'

    class { 'icinga::db::database':
      db_type          => $db_type,
      db_name          => $db_name,
      db_user          => $db_user,
      db_pass          => $db_pass,
      access_instances => concat($db_accesses, ['localhost']),
      before           => Class['icingadb'],
    }
  } else {
    $_db_host = $db_host

    if $db_type != 'pgsql' {
      include mysql::client
    } else {
      include postgresql::client
    }
  }

  if $manage_redis {
    $_redis_host = 'localhost'

    class { 'icingadb::redis':
      bind        => $redis_bind,
      port        => $redis_port,
      requirepass => $redis_pass,
      before      => Class['icingadb'],
    }
  } else {
    $_redis_host = $redis_host
  }

  class { 'icingadb':
    db_type        => $db_type,
    db_host        => $_db_host,
    db_port        => $db_port,
    db_name        => $db_name,
    db_username    => $db_user,
    db_password    => $db_pass,
    import_schema  => true,
    redis_host     => $_redis_host,
    redis_port     => $redis_port,
    redis_password => $redis_pass,
  }

  if $manage_feature {
    class { 'icinga2::feature::icingadb':
      host     => $_redis_host,
      port     => $redis_port,
      password => $redis_pass,
    }
  }
}