Commit 4b5ed35a authored by Walter Heck's avatar Walter Heck

First attempt at automatically managing icinga hosts

parent c6bc9efc
Pipeline #334 failed with stages
in 2 minutes and 26 seconds
class opstheater::profile::icinga::client (
$parent_endpoints,
$parent_zone,
$agent_ip = $::facts[ipaddress],
) inherits opstheater::profile::params {
$lowercase_fqdn = downcase($::fqdn)
class { '::icinga2':
confd => false,
features => ['checker','mainlog'],
manage_repo => true,
confd => false,
features => ['checker','mainlog'],
}
class { '::icinga2::feature::api':
pki => 'none',
accept_config => true,
accept_commands => true,
endpoints => {
'NodeName' => {},
'icinga2.opstheater.vm' => {
'host' => '10.20.1.20',
}
},
zones => {
'ZoneName' => {
'endpoints' => ['NodeName'],
'parent' => 'opstheater',
},
'opstheater' => {
'endpoints' => ['icinga2.opstheater.vm'],
'ZoneName' => {
'endpoints' => [ 'NodeName' ],
'parent' => $parent_zone,
}
}
}
include opstheater::profile::filebeat::icinga::client
create_resources('icinga2::object::endpoint', $parent_endpoints)
::icinga2::object::zone { $parent_zone:
endpoints => keys($parent_endpoints),
}
@@::icinga2::object::endpoint { $::fqdn:
target => "/etc/icinga2/zones.d/${parent_zone}/${::hostname}.conf",
}
@@::icinga2::object::zone { $::fqdn:
endpoints => [ $::fqdn ],
parent => $parent_zone,
target => "/etc/icinga2/zones.d/${parent_zone}/${::hostname}.conf",
}
@@::icinga2::object::host { $::fqdn:
* => merge({
display_name => $::hostname,
address => $agent_ip,
target => "/etc/icinga2/zones.d/${parent_zone}/${::hostname}.conf",
}, hiera_hash(icinga2::host)),
}
@firewall { '201 allow access to icinga client':
chain => 'INPUT',
jump => 'OPSTHEATER',
......
......@@ -22,6 +22,14 @@ class opstheater::profile::icinga::server (
import_schema => true,
}
icinga2::object::hostgroup { 'monitoring-hosts':
display_name => 'OpsTheater Servers',
groups => [ 'opstheater-servers' ],
target => '/etc/icinga2/conf.d/groups2.conf',
assign => [ 'host.name == NodeName' ],
}
icinga2::object::zone { 'global-templates':
global => true,
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment