Skip to content

Commit

Permalink
Merge pull request #438 from Icinga:feature/add_restapi_feature_to_imc
Browse files Browse the repository at this point in the history
Feature: Adds Rest-Api check forwarder to IMC wizard

Adds the support for enabling the Rest\-Api including the Api\-Check by running the IMC installation.
  • Loading branch information
LordHepipud authored Jan 24, 2022
2 parents c88897e + 4d4d9ca commit 28f9f27
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/100-General/10-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
23 changes: 22 additions & 1 deletion lib/core/installer/Start-IcingaForWindowsInstallation.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @();
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/core/installer/menu/installation/AdvancedEntries.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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';

0 comments on commit 28f9f27

Please sign in to comment.