Skip to content

Commit

Permalink
Merge pull request #723 from Icinga/puppetdb-query
Browse files Browse the repository at this point in the history
Add feature to handle large monitoring environments
  • Loading branch information
lbetz authored Mar 22, 2023
2 parents aebbdb3 + 63b3349 commit fd39e2c
Show file tree
Hide file tree
Showing 23 changed files with 416 additions and 85 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
Icinga 2 is a widely used open source monitoring software. This Puppet module helps with installing and managing
configuration of Icinga 2 on multiple operating systems.

### What's new in version 3.6.0
Each Icinga object has been given the new parameter `export` that specifies one (ordinary objects for the config server) or more nodes (e.g. zones and endpoints for HA servers from workers aka satellites) as targets where the objects are then created using the class `query_objects`. This has been implemented to avoid collecting export resources in large environments.

### What's new in version 3.5.0
There are some new function for internal use. Function `icinga2::cert` handels files and/or content for TLS client auth for bot IDO features and for influxdb, infuxdb2, elasticsearch, gelf and icingadb. The function `icinga2::db::connect` provides the client connection string to mysql, mariadb or pgsql databses for both IDO features.

Expand Down Expand Up @@ -97,7 +100,7 @@ The use of Icinga's own CA is recommended. If you still want to use the Puppet c
This module has been tested on:

* Debian 10, 11
* Ubuntu 18.04, 20.04, 22.04
* Ubuntu 20.04, 22.04
* CentOS/RHEL 7, 8, 9
* AlmaLinux/Rocky 8, 9
* Fedora 32
Expand Down
17 changes: 16 additions & 1 deletion manifests/object/apiuser.pp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
# @param [Variant[String, Integer]] order
# String or integer to set the position in the target file, sorted alpha numeric.
#
# @param export
# Export object to destination, collected by class `icinga2::query_objects`.
#
define icinga2::object::apiuser (
Stdlib::Absolutepath $target,
Enum['absent', 'present'] $ensure = present,
Expand All @@ -65,6 +68,7 @@
Optional[Variant[String, Sensitive[String]]] $password = undef,
Optional[String] $client_cn = undef,
Variant[String, Integer] $order = 30,
Variant[Array[String], String] $export = [],
) {
$_password = if $password =~ String {
Sensitive($password)
Expand All @@ -82,7 +86,7 @@
}

# create object
icinga2::object { "icinga2::object::ApiUser::${title}":
$config = {
ensure => $ensure,
object_name => $apiuser_name,
object_type => 'ApiUser',
Expand All @@ -91,4 +95,15 @@
target => $target,
order => $order,
}

unless empty($export) {
@@icinga2::object { "icinga2::object::ApiUser::${title}":
tag => prefix(any2array($export), 'icinga2::instance::'),
* => $config,
}
} else {
icinga2::object { "icinga2::object::ApiUser::${title}":
* => $config,
}
}
}
16 changes: 15 additions & 1 deletion manifests/object/checkcommand.pp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
# @param order
# String or integer to set the position in the target file, sorted alpha numeric.
#
# @param export
# Export object to destination, collected by class `icinga2::query_objects`.
#
define icinga2::object::checkcommand (
Stdlib::Absolutepath $target,
Expand All @@ -52,6 +54,7 @@
Optional[Variant[Hash, String]] $arguments = undef,
Boolean $template = false,
Variant[String, Integer] $order = 15,
Variant[Array[String], String] $export = [],
) {
# compose the attributes
$attrs = {
Expand All @@ -63,7 +66,7 @@
}

# create object
icinga2::object { "icinga2::object::CheckCommand::${title}":
$config = {
ensure => $ensure,
object_name => $checkcommand_name,
object_type => 'CheckCommand',
Expand All @@ -74,4 +77,15 @@
target => $target,
order => $order,
}

unless empty($export) {
@@icinga2::object { "icinga2::object::CheckCommand::${title}":
tag => prefix(any2array($export), 'icinga2::instance::'),
* => $config,
}
} else {
icinga2::object { "icinga2::object::CheckCommand::${title}":
* => $config,
}
}
}
57 changes: 36 additions & 21 deletions manifests/object/dependency.pp
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,31 @@
# @param order
# String or integer to set the position in the target file, sorted alpha numeric.
#
# @param export
# Export object to destination, collected by class `icinga2::query_objects`.
#
define icinga2::object::dependency (
Stdlib::Absolutepath $target,
Enum['absent', 'present'] $ensure = present,
String $dependency_name = $title,
Optional[String] $parent_host_name = undef,
Optional[String] $parent_service_name = undef,
Optional[String] $child_host_name = undef,
Optional[String] $child_service_name = undef,
Optional[Boolean] $disable_checks = undef,
Optional[Boolean] $disable_notifications = undef,
Optional[Boolean] $ignore_soft_states = undef,
Optional[String] $period = undef,
Optional[Array] $states = undef,
Variant[Boolean, String] $apply = false,
Variant[Boolean, String] $prefix = false,
Enum['Host', 'Service'] $apply_target = 'Host',
Array $assign = [],
Array $ignore = [],
Array $import = [],
Boolean $template = false,
Variant[String, Integer] $order = 70,
Stdlib::Absolutepath $target,
Enum['absent', 'present'] $ensure = present,
String $dependency_name = $title,
Optional[String] $parent_host_name = undef,
Optional[String] $parent_service_name = undef,
Optional[String] $child_host_name = undef,
Optional[String] $child_service_name = undef,
Optional[Boolean] $disable_checks = undef,
Optional[Boolean] $disable_notifications = undef,
Optional[Boolean] $ignore_soft_states = undef,
Optional[String] $period = undef,
Optional[Array] $states = undef,
Variant[Boolean, String] $apply = false,
Variant[Boolean, String] $prefix = false,
Enum['Host', 'Service'] $apply_target = 'Host',
Array $assign = [],
Array $ignore = [],
Array $import = [],
Boolean $template = false,
Variant[String, Integer] $order = 70,
Variant[Array[String], String] $export = [],
) {
# compose attributes
$attrs = {
Expand All @@ -104,7 +108,7 @@
}

# create object
icinga2::object { "icinga2::object::Dependency::${title}":
$config = {
ensure => $ensure,
object_name => $dependency_name,
object_type => 'Dependency',
Expand All @@ -120,4 +124,15 @@
target => $target,
order => $order,
}

unless empty($export) {
@@icinga2::object { "icinga2::object::Dependency::${title}":
tag => prefix(any2array($export), 'icinga2::instance::'),
* => $config,
}
} else {
icinga2::object { "icinga2::object::Dependency::${title}":
* => $config,
}
}
}
17 changes: 16 additions & 1 deletion manifests/object/endpoint.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
# @param order
# String or integer to set the position in the target file, sorted alpha numeric.
#
# @param export
# Export object to destination, collected by class `icinga2::query_objects`.
#
define icinga2::object::endpoint (
Enum['absent', 'present'] $ensure = present,
String $endpoint_name = $title,
Expand All @@ -34,6 +37,7 @@
Optional[Icinga2::Interval] $log_duration = undef,
Optional[Stdlib::Absolutepath] $target = undef,
Variant[String, Integer] $order = 40,
Variant[Array[String], String] $export = [],
) {
$conf_dir = $icinga2::globals::conf_dir

Expand All @@ -51,7 +55,7 @@
}

# create object
icinga2::object { "icinga2::object::Endpoint::${title}":
$config = {
ensure => $ensure,
object_name => $endpoint_name,
object_type => 'Endpoint',
Expand All @@ -60,4 +64,15 @@
target => $_target,
order => $order,
}

unless empty($export) {
@@icinga2::object { "icinga2::object::Endpoint::${title}":
tag => prefix(any2array($export), 'icinga2::instance::'),
* => $config,
}
} else {
icinga2::object { "icinga2::object::Endpoint::${title}":
* => $config,
}
}
}
17 changes: 16 additions & 1 deletion manifests/object/eventcommand.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
# @param order
# String or integer to set the position in the target file, sorted alpha numeric.
#
# @param export
# Export object to destination, collected by class `icinga2::query_objects`.
#
define icinga2::object::eventcommand (
Stdlib::Absolutepath $target,
Enum['absent', 'present'] $ensure = present,
Expand All @@ -47,6 +50,7 @@
Optional[Hash] $arguments = undef,
Array $import = [],
Variant[String, Integer] $order = 20,
Variant[Array[String], String] $export = [],
) {
# compose the attributes
$attrs = {
Expand All @@ -58,7 +62,7 @@
}

# create object
icinga2::object { "icinga2::object::EventCommand::${title}":
$config = {
ensure => $ensure,
object_name => $eventcommand_name,
object_type => 'EventCommand',
Expand All @@ -68,4 +72,15 @@
target => $target,
order => $order,
}

unless empty($export) {
@@icinga2::object { "icinga2::object::EventCommand::${title}":
tag => prefix(any2array($export), 'icinga2::instance::'),
* => $config,
}
} else {
icinga2::object { "icinga2::object::EventCommand::${title}":
* => $config,
}
}
}
17 changes: 16 additions & 1 deletion manifests/object/host.pp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
# @param order
# String or integer to set the position in the target file, sorted alpha numeric.
#
# @param export
# Export object to destination, collected by class `icinga2::query_objects`.
#
define icinga2::object::host (
Stdlib::Absolutepath $target,
Enum['absent', 'present'] $ensure = present,
Expand Down Expand Up @@ -142,6 +145,7 @@
Optional[String] $icon_image_alt = undef,
Boolean $template = false,
Variant[String, Integer] $order = 50,
Variant[Array[String], String] $export = [],
) {
# compose the attributes
$attrs = {
Expand Down Expand Up @@ -176,7 +180,7 @@
}

# create object
icinga2::object { "icinga2::object::Host::${title}":
$config = {
ensure => $ensure,
object_name => $host_name,
object_type => 'Host',
Expand All @@ -187,4 +191,15 @@
target => $target,
order => $order,
}

unless empty($export) {
@@icinga2::object { "icinga2::object::Host::${title}":
tag => prefix(any2array($export), 'icinga2::instance::'),
* => $config,
}
} else {
icinga2::object { "icinga2::object::Host::${title}":
* => $config,
}
}
}
33 changes: 24 additions & 9 deletions manifests/object/hostgroup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,19 @@
# @param order
# String or integer to set the position in the target file, sorted alpha numeric.
#
# @param export
# Export object to destination, collected by class `icinga2::query_objects`.
#
define icinga2::object::hostgroup (
Stdlib::Absolutepath $target,
Enum['absent', 'present'] $ensure = present,
String $hostgroup_name = $title,
Optional[String] $display_name = undef,
Optional[Array] $groups = undef,
Array $assign = [],
Array $ignore = [],
Variant[String, Integer] $order = 55,
Stdlib::Absolutepath $target,
Enum['absent', 'present'] $ensure = present,
String $hostgroup_name = $title,
Optional[String] $display_name = undef,
Optional[Array] $groups = undef,
Array $assign = [],
Array $ignore = [],
Variant[String, Integer] $order = 55,
Variant[Array[String], String] $export = [],
) {
if $ignore != [] and $assign == [] {
fail('When attribute ignore is used, assign must be set.')
Expand All @@ -55,7 +59,7 @@
}

# create object
icinga2::object { "icinga2::object::HostGroup::${title}":
$config = {
ensure => $ensure,
object_name => $hostgroup_name,
object_type => 'HostGroup',
Expand All @@ -66,4 +70,15 @@
target => $target,
order => $order,
}

unless empty($export) {
@@icinga2::object { "icinga2::object::HostGroup::${title}":
tag => prefix(any2array($export), 'icinga2::instance::'),
* => $config,
}
} else {
icinga2::object { "icinga2::object::HostGroup::${title}":
* => $config,
}
}
}
Loading

0 comments on commit fd39e2c

Please sign in to comment.