From 4b7b86785fcbbd4e9239c3befcc0d9e440712c68 Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Thu, 19 Aug 2021 14:19:22 +0200 Subject: [PATCH] Fixies various Icinga Director IMC issues --- lib/core/installer/Install-Icinga.psm1 | 44 ++++++++++--------- .../director/DirectorTemplate.psm1 | 12 ++++- .../installation/director/DirectorUrl.psm1 | 2 + .../installation/general/FinishInstaller.psm1 | 7 ++- .../installation/icinga/SelectConnection.psm1 | 2 + 5 files changed, 44 insertions(+), 23 deletions(-) diff --git a/lib/core/installer/Install-Icinga.psm1 b/lib/core/installer/Install-Icinga.psm1 index 0e96883..8cbcb3f 100644 --- a/lib/core/installer/Install-Icinga.psm1 +++ b/lib/core/installer/Install-Icinga.psm1 @@ -12,27 +12,29 @@ function Install-Icinga() if ($global:Icinga.ContainsKey('InstallWizard') -eq $FALSE) { $global:Icinga.Add( 'InstallWizard', @{ - 'AdminShell' = (Test-AdministrativeShell); - 'LastInput' = ''; - 'LastNotice' = ''; - 'LastError' = ''; - 'HeaderPreview' = ''; - 'LastParent' = [System.Collections.ArrayList]@(); - 'LastValues' = @(); - 'Config' = @{ }; - 'ConfigSwap' = @{ }; - 'ParentConfig' = $null; - 'Menu' = 'Install-Icinga'; - 'NextCommand' = ''; - 'NextArguments' = $null; - 'HeaderSelection' = $null; - 'DisplayAdvanced' = $FALSE; - 'ShowAdvanced' = $FALSE; - 'ShowHelp' = $FALSE; - 'DeleteValues' = $FALSE; - 'HeaderPrint' = $FALSE; - 'JumpToSummary' = $FALSE; - 'Closing' = $FALSE; + 'AdminShell' = (Test-AdministrativeShell); + 'LastInput' = ''; + 'LastNotice' = ''; + 'LastError' = ''; + 'HeaderPreview' = ''; + 'DirectorSelfService' = $FALSE; + 'DirectorRegisteredHost' = $FALSE; + 'LastParent' = [System.Collections.ArrayList]@(); + 'LastValues' = @(); + 'Config' = @{ }; + 'ConfigSwap' = @{ }; + 'ParentConfig' = $null; + 'Menu' = 'Install-Icinga'; + 'NextCommand' = ''; + 'NextArguments' = $null; + 'HeaderSelection' = $null; + 'DisplayAdvanced' = $FALSE; + 'ShowAdvanced' = $FALSE; + 'ShowHelp' = $FALSE; + 'DeleteValues' = $FALSE; + 'HeaderPrint' = $FALSE; + 'JumpToSummary' = $FALSE; + 'Closing' = $FALSE; } ); } diff --git a/lib/core/installer/menu/installation/director/DirectorTemplate.psm1 b/lib/core/installer/menu/installation/director/DirectorTemplate.psm1 index 70d26f9..e0133ef 100644 --- a/lib/core/installer/menu/installation/director/DirectorTemplate.psm1 +++ b/lib/core/installer/menu/installation/director/DirectorTemplate.psm1 @@ -15,6 +15,7 @@ function Resolve-IcingaForWindowsManagementConsoleInstallationDirectorTemplate() Add-IcingaForWindowsInstallerConfigEntry -Selection 'c' -Values $DirectorUrl -OverwriteValues -OverwriteMenu 'Show-IcingaForWindowsManagementConsoleInstallationEnterDirectorUrl'; Add-IcingaForWindowsInstallerConfigEntry -Selection 'c' -Values $SelfServiceKey -OverwriteValues -OverwriteMenu 'Show-IcingaForWindowsManagementConsoleInstallationEnterDirectorSelfServiceKey'; } else { + $Global:Icinga.InstallWizard.DirectorRegisteredHost = $TRUE; $HostnameType = Get-IcingaForWindowsInstallerStepSelection -InstallerStep 'Show-IcingaForWindowsInstallerMenuSelectHostname'; $Hostname = ''; @@ -76,7 +77,7 @@ function Resolve-IcingaForWindowsManagementConsoleInstallationDirectorTemplate() $ServiceUserName = $DirectorConfig.icinga_service_user; $AgentPackageSelection = 1; #Always use custom source $AgentPackageSource = $DirectorConfig.download_url; - $AgentVersion = $DirectorConfig.release; + $AgentVersion = $DirectorConfig.agent_version; $IcingaPort = $DirectorConfig.agent_listen_port; $GlobalZones = @(); $IcingaParents = @(); @@ -174,6 +175,13 @@ function Resolve-IcingaForWindowsManagementConsoleInstallationDirectorTemplate() } Disable-IcingaFrameworkConsoleOutput; + + $HostRegisterSetting = (Get-IcingaForWindowsInstallerStepSelection -InstallerStep 'Show-IcingaForWindowsInstallerMenuSelectHostname'); + + if ($null -ne $HostRegisterSetting -And $HostnameSelection -ne $HostRegisterSetting) { + $HostnameSelection = $HostRegisterSetting; + } + Show-IcingaForWindowsInstallerMenuSelectHostname -DefaultInput $HostnameSelection -Automated; Add-IcingaForWindowsInstallationAdvancedEntries; Disable-IcingaFrameworkConsoleOutput; @@ -194,6 +202,8 @@ function Resolve-IcingaForWindowsManagementConsoleInstallationDirectorTemplate() Show-IcingaForWindowsInstallerMenuSelectCertificate -Automated -DefaultInput '1'; Show-IcingaForWindowsInstallerMenuEnterIcingaTicket -Automated -Value $Ticket; + Show-IcingaForWindowsInstallationMenuEnterIcingaAgentVersion -Automated -Value $AgentVersion; + Show-IcingaForWindowsManagementConsoleInstallationDirectorRegisterHost -Automated; Enable-IcingaFrameworkConsoleOutput; diff --git a/lib/core/installer/menu/installation/director/DirectorUrl.psm1 b/lib/core/installer/menu/installation/director/DirectorUrl.psm1 index 82b1ea3..ed069b5 100644 --- a/lib/core/installer/menu/installation/director/DirectorUrl.psm1 +++ b/lib/core/installer/menu/installation/director/DirectorUrl.psm1 @@ -8,6 +8,8 @@ function Show-IcingaForWindowsManagementConsoleInstallationEnterDirectorUrl() [switch]$Advanced = $FALSE ); + $Global:Icinga.InstallWizard.DirectorSelfService = $TRUE; + Show-IcingaForWindowsInstallerMenu ` -Header 'Please enter the URL pointing to your Icinga Director module:' ` -Entries @( diff --git a/lib/core/installer/menu/installation/general/FinishInstaller.psm1 b/lib/core/installer/menu/installation/general/FinishInstaller.psm1 index 89a404f..2d7f08c 100644 --- a/lib/core/installer/menu/installation/general/FinishInstaller.psm1 +++ b/lib/core/installer/menu/installation/general/FinishInstaller.psm1 @@ -1,5 +1,10 @@ function Show-IcingaForWindowsInstallerMenuFinishInstaller() { + + if ($global:Icinga.InstallWizard.DirectorSelfService -eq $TRUE -And $global:Icinga.InstallWizard.DirectorRegisteredHost -eq $FALSE) { + $global:Icinga.InstallWizard.LastNotice = 'To install this host while using "Icinga Director Self-Service API", you need to register the host in the previous step first.'; + } + Show-IcingaForWindowsInstallerMenu ` -Header 'How you do want to proceed:' ` -Entries @( @@ -7,7 +12,7 @@ function Show-IcingaForWindowsInstallerMenuFinishInstaller() 'Caption' = 'Start installation'; 'Command' = 'Start-IcingaForWindowsInstallation'; 'Help' = 'Apply the just configured configuration and install components as selected'; - 'Disabled' = (-Not ($global:Icinga.InstallWizard.AdminShell)); + 'Disabled' = (-Not ($global:Icinga.InstallWizard.AdminShell) -Or ($global:Icinga.InstallWizard.DirectorSelfService -eq $TRUE -And $global:Icinga.InstallWizard.DirectorRegisteredHost -eq $FALSE)); 'Action' = @{ 'Command' = 'Clear-IcingaForWindowsManagementConsolePaginationCache'; } diff --git a/lib/core/installer/menu/installation/icinga/SelectConnection.psm1 b/lib/core/installer/menu/installation/icinga/SelectConnection.psm1 index b7db5f7..e0c3be7 100644 --- a/lib/core/installer/menu/installation/icinga/SelectConnection.psm1 +++ b/lib/core/installer/menu/installation/icinga/SelectConnection.psm1 @@ -8,6 +8,8 @@ function Show-IcingaForWindowsInstallerMenuSelectConnection() [switch]$Advanced = $FALSE ); + $Global:Icinga.InstallWizard.DirectorSelfService = $FALSE; + Show-IcingaForWindowsInstallerMenu ` -Header 'How do you want to configure your local Icinga Agent?' ` -Entries @(