Puppet Class: icinga::ido

Defined in:
manifests/ido.pp

Summary

Configure IDO Backend.

Overview

Parameters:

  • db_pass (Icinga::Secret)

    Password to connect the database.

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

    What kind of database type to use.

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

    Database host to connect.

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

    Port to connect. Only affects for connection to remote database hosts.

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

    Name of the database.

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

    Database user name.

  • manage_database (Boolean) (defaults to: false)

    Create database and import schema.

  • enable_ha (Boolean) (defaults to: false)

    Enable HA feature for database.



28
29
30
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
92
93
94
95
96
97
98
99
100
101
102
# File 'manifests/ido.pp', line 28

class icinga::ido (
  Icinga::Secret                         $db_pass,
  Enum['mysql','pgsql']                  $db_type         = 'mysql',
  Stdlib::Host                           $db_host         = 'localhost',
  Optional[Stdlib::Port]                 $db_port         = undef,
  String                                 $db_name         = 'icinga2',
  String                                 $db_user         = 'icinga2',
  Boolean                                $manage_database = false,
  Boolean                                $enable_ha       = false,
) {
  unless $db_port {
    $_db_port = $db_type ? {
      'pgsql' => 5432,
      default => 3306,
    }
  } else {
    $_db_port = $db_port
  }

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

  if $manage_database {
    class { 'icinga::ido::database':
      db_type       => $db_type,
      db_name       => $db_name,
      db_user       => $db_user,
      db_pass       => $db_pass,
      ido_instances => [$db_host],
      before        => Class["icinga2::feature::ido${db_type}"],
    }
  }
#  } else {
#    if $db_type != 'pgsql' {
#      include mysql::client
#    } else {
#      include postgresql::client
#    }
#  }

  if $facts['kernel'] == 'linux' {
    $ido_package_name = $db_type ? {
      'mysql' => $icinga2::globals::ido_mysql_package_name,
      'pgsql' => $icinga2::globals::ido_pgsql_package_name,
    }

    if $facts['os']['family'] == 'debian' {
      ensure_resources('file', { '/etc/dbconfig-common' => { ensure => directory, owner => 'root', group => 'root' } })
      file { "/etc/dbconfig-common/${ido_package_name}.conf":
        ensure  => file,
        content => "dbc_install='false'\ndbc_upgrade='false'\ndbc_remove='false'\n",
        mode    => '0600',
        before  => Package[$ido_package_name],
      }
    } # Debian

    package { $ido_package_name:
      ensure => installed,
      before => Class["icinga2::feature::ido${db_type}"],
    }
  } # Linux

  class { "icinga2::feature::ido${db_type}":
    host          => $db_host,
    port          => $_db_port,
    database      => $db_name,
    user          => $db_user,
    password      => $db_pass,
    import_schema => true,
    enable_ha     => $enable_ha,
  }
}