| 
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,
    }
  }
} |