diff --git a/doc/100-General/10-Changelog.md b/doc/100-General/10-Changelog.md index 5e5c9c1..3b88815 100644 --- a/doc/100-General/10-Changelog.md +++ b/doc/100-General/10-Changelog.md @@ -32,6 +32,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic * [#388](https://github.com/Icinga/icinga-powershell-framework/issues/388) Improves performance for testing if `Add-Type` functions have been added, by adding an internal test for newly introduced environment variables within a PowerShell session * [#417](https://github.com/Icinga/icinga-powershell-framework/issues/417) Adds support to allow the force creation of Icinga Agent certificates, even when they are already present on the system over Icinga Management Console installation * [#427](https://github.com/Icinga/icinga-powershell-framework/issues/427) Moves Icinga for Windows EventLog from `Application` to a custom log `Icinga for Windows`, allowing better separation +* [#438](https://github.com/Icinga/icinga-powershell-framework/pull/438) Adds support for enabling the REST-Api background daemon and the Api-Check feature during the IMC installation wizard on advanced settings, which will be enabled by default ## 1.7.1 (2021-11-11) diff --git a/lib/core/installer/Start-IcingaForWindowsInstallation.psm1 b/lib/core/installer/Start-IcingaForWindowsInstallation.psm1 index 7b5b4a5..6522a62 100644 --- a/lib/core/installer/Start-IcingaForWindowsInstallation.psm1 +++ b/lib/core/installer/Start-IcingaForWindowsInstallation.psm1 @@ -56,6 +56,9 @@ function Start-IcingaForWindowsInstallation() # JEA Profile $InstallJEAProfile = Get-IcingaForWindowsInstallerStepSelection -InstallerStep 'Show-IcingaForWindowsInstallerMenuSelectInstallJEAProfile'; + # Api Checks + $InstallApiChecks = Get-IcingaForWindowsInstallerStepSelection -InstallerStep 'Show-IcingaForWindowsInstallerMenuSelectInstallApiChecks'; + $Hostname = ''; $GlobalZones = @(); $IcingaParentAddresses = @(); @@ -255,7 +258,25 @@ function Start-IcingaForWindowsInstallation() }; '2' { # Do not install JEA profile - } + }; + } + + switch ($InstallApiChecks) { + '0' { + Disable-IcingaFrameworkApiChecks; + break; + }; + '1' { + Register-IcingaBackgroundDaemon -Command 'Start-IcingaWindowsRESTApi'; + Add-IcingaRESTApiCommand -Command 'Invoke-IcingaCheck*' -Endpoint 'apichecks'; + Enable-IcingaFrameworkApiChecks; + if ($InstallService) { + Restart-IcingaWindowsService; + } else { + Write-IcingaConsoleWarning -Message 'You have selected to install the Api-Check feature and all required configurations were made. The Icinga for Windows service is however not marked for installation, which will cause this feature to not work.'; + } + break; + }; } # Update configuration and clear swap diff --git a/lib/core/installer/menu/installation/AdvancedEntries.psm1 b/lib/core/installer/menu/installation/AdvancedEntries.psm1 index 0a70c95..197e725 100644 --- a/lib/core/installer/menu/installation/AdvancedEntries.psm1 +++ b/lib/core/installer/menu/installation/AdvancedEntries.psm1 @@ -25,6 +25,7 @@ function Add-IcingaForWindowsInstallationAdvancedEntries() Show-IcingaForWindowsInstallationMenuStableRepository -Automated -Advanced; Show-IcingaForWindowsInstallerMenuSelectInstallJEAProfile -Automated -Advanced; Show-IcingaForWindowsInstallationMenuEnterIcingaCAServer -Automated -Advanced; + Show-IcingaForWindowsInstallerMenuSelectInstallApiChecks -Automated -Advanced; Enable-IcingaFrameworkConsoleOutput; diff --git a/lib/core/installer/menu/installation/framework/InstallApiChecks.psm1 b/lib/core/installer/menu/installation/framework/InstallApiChecks.psm1 new file mode 100644 index 0000000..b637604 --- /dev/null +++ b/lib/core/installer/menu/installation/framework/InstallApiChecks.psm1 @@ -0,0 +1,32 @@ +function Show-IcingaForWindowsInstallerMenuSelectInstallApiChecks() +{ + param ( + [array]$Value = @(), + [string]$DefaultInput = '1', + [switch]$JumpToSummary = $FALSE, + [switch]$Automated = $FALSE, + [switch]$Advanced = $FALSE + ); + + Show-IcingaForWindowsInstallerMenu ` + -Header 'Please select if you want to enable the Api-Checks feature' ` + -Entries @( + @{ + 'Caption' = 'Do not install Api-Checks feature'; + 'Command' = 'Show-IcingaForWindowsInstallerConfigurationSummary'; + 'Help' = 'Does neither register the REST-Api background daemon nor enables the Api-Check feature'; + }, + @{ + 'Caption' = 'Install Api-Checks feature'; + 'Command' = 'Show-IcingaForWindowsInstallerConfigurationSummary'; + 'Help' = 'Enables the Icinga for Windows REST-Api background daemon and enables the Api-Check feature, which results in every check executed by "Exit-IcingaExecutePlugin" to be forwarded to the internal API. This will provide a huge performance boost for plugin execution. Also enables all checks for the namespace "Invoke-IcingaCheck*" to be executed over the Api. The REST-Api is only configured to run on localhost. Requires the Icinga for Windows service to be installed.'; + } + ) ` + -DefaultIndex $DefaultInput ` + -JumpToSummary:$FALSE ` + -ConfigElement ` + -Automated:$Automated ` + -Advanced:$Advanced; +} + +Set-Alias -Name 'IfW-InstallApiChecks' -Value 'Show-IcingaForWindowsInstallerMenuSelectInstallApiChecks';