Skip to content

Commit

Permalink
Merge pull request #104 from Icinga/enhancement/add-eventlog-support
Browse files Browse the repository at this point in the history
Add eventlog support on Windows platforms
  • Loading branch information
lbetz authored Dec 31, 2023
2 parents aab98ee + f69d8c9 commit d8f44ec
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 56 deletions.
12 changes: 6 additions & 6 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ Default value: `[]`

##### <a name="-icinga--agent--logging_type"></a>`logging_type`

Data type: `Enum['file', 'syslog']`
Data type: `Enum['file', 'syslog', 'eventlog']`

Switch the log target. Only `file` is supported on Windows.
Switch the log target. On Windows `syslog` is ignored, `eventlog` on all other platforms.

Default value: `'file'`

Expand Down Expand Up @@ -706,9 +706,9 @@ Default value: `undef`

##### <a name="-icinga--server--logging_type"></a>`logging_type`

Data type: `Enum['file', 'syslog']`
Data type: `Enum['file', 'syslog', 'eventlog']`

Switch the log target. Only `file` is supported on Windows.
Switch the log target. On Windows `syslog` is ignored, `eventlog` on all other platforms.

Default value: `'file'`

Expand Down Expand Up @@ -1831,9 +1831,9 @@ Default value: `[]`

##### <a name="-icinga--worker--logging_type"></a>`logging_type`

Data type: `Enum['file', 'syslog']`
Data type: `Enum['file', 'syslog', 'eventlog']`

Switch the log target. Only `file` is supported on Windows.
Switch the log target. On Windows `syslog` is ignored, `eventlog` on all other platforms.

Default value: `'file'`

Expand Down
18 changes: 9 additions & 9 deletions manifests/agent.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# List of global zones to configure.
#
# @param logging_type
# Switch the log target. Only `file` is supported on Windows.
# Switch the log target. On Windows `syslog` is ignored, `eventlog` on all other platforms.
#
# @param logging_level
# Set the log level.
Expand All @@ -27,14 +27,14 @@
# and add the Icinga user to this group.
#
class icinga::agent (
Stdlib::Host $ca_server,
Hash[String, Hash] $parent_endpoints,
String $parent_zone = 'main',
Array[String] $global_zones = [],
Enum['file', 'syslog'] $logging_type = 'file',
Optional[Icinga::LogLevel] $logging_level = undef,
String $zone = 'NodeName',
Boolean $run_web = false,
Stdlib::Host $ca_server,
Hash[String, Hash] $parent_endpoints,
String $parent_zone = 'main',
Array[String] $global_zones = [],
Enum['file', 'syslog', 'eventlog'] $logging_type = 'file',
Optional[Icinga::LogLevel] $logging_level = undef,
String $zone = 'NodeName',
Boolean $run_web = false,
) {
class { 'icinga':
ca => false,
Expand Down
42 changes: 28 additions & 14 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# to authenticate the certificate request againt the CA on host `ca_server`.
#
# @param logging_type
# Switch the log target. Only `file` is supported on Windows.
# Switch the log target. On Windows `syslog` is ignored, `eventlog` on all other platforms.
#
# @param logging_level
# Set the log level.
Expand All @@ -56,7 +56,7 @@
Optional[Stdlib::Host] $ca_server = undef,
Optional[Icinga::Secret] $ticket_salt = undef,
Array[String] $extra_packages = [],
Enum['file', 'syslog'] $logging_type = 'file',
Enum['file', 'syslog', 'eventlog'] $logging_type = 'file',
Optional[Icinga::LogLevel] $logging_level = undef,
String $cert_name = $facts['networking']['fqdn'],
Boolean $prepare_web = false,
Expand Down Expand Up @@ -90,26 +90,40 @@
features => [],
}

# switch logging between mainlog and syslog
# logging on windows only file is supported, warning output see below
if $logging_type == 'file' or $facts['kernel'] == 'windows' {
$_mainlog = 'present'
$_syslog = 'absent'
# switch logging between mainlog, syslog and eventlog
if $facts['kernel'] != 'windows' {
if $logging_type == 'file' {
$_mainlog = 'present'
$_syslog = 'absent'
} else {
$_mainlog = 'absent'
$_syslog = 'present'
}

class { 'icinga2::feature::syslog':
ensure => $_syslog,
severity => $logging_level,
}
} else {
$_mainlog = 'absent'
$_syslog = 'present'
if $logging_type == 'file' {
$_mainlog = 'present'
$_eventlog = 'absent'
} else {
$_mainlog = 'absent'
$_eventlog = 'present'
}

class { 'icinga2::feature::windowseventlog':
ensure => $_eventlog,
severity => $logging_level,
}
}

class { 'icinga2::feature::mainlog':
ensure => $_mainlog,
severity => $logging_level,
}

class { 'icinga2::feature::syslog':
ensure => $_syslog,
severity => $logging_level,
}

case $facts['kernel'] {
'linux': {
$icinga_user = $icinga2::globals::user
Expand Down
32 changes: 16 additions & 16 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
# Icinga API director user password.
#
# @param logging_type
# Switch the log target. Only `file` is supported on Windows.
# Switch the log target. On Windows `syslog` is ignored, `eventlog` on all other platforms.
#
# @param logging_level
# Set the log level.
Expand All @@ -49,21 +49,21 @@
# and add the Icinga user to this group.
#
class icinga::server (
Boolean $ca = false,
Boolean $config_server = false,
String $zone = 'main',
Hash[String,Hash] $colocation_endpoints = {},
Hash[String,Hash] $workers = {},
Array[String] $global_zones = [],
Optional[Stdlib::Host] $ca_server = undef,
Optional[Icinga::Secret] $ticket_salt = undef,
String $web_api_user = 'icingaweb2',
Optional[Icinga::Secret] $web_api_pass = undef,
String $director_api_user = 'director',
Optional[Icinga::Secret] $director_api_pass = undef,
Enum['file', 'syslog'] $logging_type = 'file',
Optional[Icinga::LogLevel] $logging_level = undef,
Boolean $run_web = false,
Boolean $ca = false,
Boolean $config_server = false,
String $zone = 'main',
Hash[String,Hash] $colocation_endpoints = {},
Hash[String,Hash] $workers = {},
Array[String] $global_zones = [],
Optional[Stdlib::Host] $ca_server = undef,
Optional[Icinga::Secret] $ticket_salt = undef,
String $web_api_user = 'icingaweb2',
Optional[Icinga::Secret] $web_api_pass = undef,
String $director_api_user = 'director',
Optional[Icinga::Secret] $director_api_pass = undef,
Enum['file', 'syslog', 'eventlog'] $logging_type = 'file',
Optional[Icinga::LogLevel] $logging_level = undef,
Boolean $run_web = false,
) {
if empty($colocation_endpoints) {
$_ca = true
Expand Down
22 changes: 11 additions & 11 deletions manifests/worker.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# List of global zones to configure.
#
# @param logging_type
# Switch the log target. Only `file` is supported on Windows.
# Switch the log target. On Windows `syslog` is ignored, `eventlog` on all other platforms.
#
# @param logging_level
# Set the log level.
Expand All @@ -34,16 +34,16 @@
# and add the Icinga user to this group.
#
class icinga::worker (
Stdlib::Host $ca_server,
String $zone,
Hash[String, Hash] $parent_endpoints,
String $parent_zone = 'main',
Hash[String, Hash] $colocation_endpoints = {},
Hash[String, Hash] $workers = {},
Array[String] $global_zones = [],
Enum['file', 'syslog'] $logging_type = 'file',
Optional[Icinga::LogLevel] $logging_level = undef,
Boolean $run_web = false,
Stdlib::Host $ca_server,
String $zone,
Hash[String, Hash] $parent_endpoints,
String $parent_zone = 'main',
Hash[String, Hash] $colocation_endpoints = {},
Hash[String, Hash] $workers = {},
Array[String] $global_zones = [],
Enum['file', 'syslog', 'eventlog'] $logging_type = 'file',
Optional[Icinga::LogLevel] $logging_level = undef,
Boolean $run_web = false,
) {
# inject parent zone if no parent exists
$_workers = $workers.reduce({}) |$memo, $worker| { $memo + { $worker[0] => { parent => $zone } + $worker[1] } }
Expand Down

0 comments on commit d8f44ec

Please sign in to comment.