Skip to content

Commit 9c545f2

Browse files
authored
Merge pull request #478 from Icinga:fix/parent_connection_not_asking_for_ca_crt
Fix: Option "Connecting from parent system" is not asking for ca.crt While using the IMC with the connection option "Connecting from parent system", the wizard is not asking for the location of the ca.crt, which is required in order to complete the Icinga Agent process and ensure the API feature can be enabled afterwards. Before, the user had to manually configure this step, which required knowledge on how this process works for Icinga.
2 parents e17c416 + 1c88fe2 commit 9c545f2

File tree

5 files changed

+43
-3
lines changed

5 files changed

+43
-3
lines changed

doc/100-General/10-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1414
### Bugfixes
1515

1616
* [#472](https://github.com/Icinga/icinga-powershell-framework/pull/472) Fixes random errors while dynamically compiling Add-Type code by now writing a DLL inside `cache/dll` for later usage
17+
* [#478](https://github.com/Icinga/icinga-powershell-framework/pull/478) Fixes connection option "Connecting from parent system" which is not asking for ca.crt location
1718

1819
### Enhancements
1920

lib/core/installer/menu/installation/AdvancedEntries.psm1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ function Add-IcingaForWindowsInstallationAdvancedEntries()
1111

1212
Show-IcingaForWindowsInstallationMenuEnterIcingaPort -Automated -Advanced;
1313
Show-IcingaForWindowsInstallerMenuSelectOpenWindowsFirewall -DefaultInput $OpenFirewall -Automated -Advanced;
14-
Show-IcingaForWindowsInstallerMenuSelectCertificate -Automated -Advanced;
14+
# Only apply the certificate menu in case it was not selected previously, if
15+
# we choose IfW-Connection 1 for example, which tells the Parent to connect to Agent only
16+
if ($null -eq (Get-IcingaForWindowsInstallerStepSelection -InstallerStep 'Show-IcingaForWindowsInstallerMenuSelectCertificate')) {
17+
Show-IcingaForWindowsInstallerMenuSelectCertificate -Automated -Advanced;
18+
}
1519
Show-IcingaForWindowsInstallerMenuSelectForceCertificateGeneration -Automated -Advanced;
1620
Show-IcingaForWindowsInstallerMenuSelectGlobalZones -Automated -Advanced;
1721
Show-IcingaForWindowsInstallationMenuEnterCustomGlobalZones -Automated -Advanced;

lib/core/installer/menu/installation/certificate/EnterIcingaCAFile.psm1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ function Show-IcingaForWindowsInstallerMenuEnterIcingaCAFile()
2727
-ConfigElement `
2828
-Automated:$Automated `
2929
-Advanced:$Advanced;
30+
31+
# By default, we are never prompt to enter the CA target path, unless we are connecting
32+
# from Parent->Agent, which is option 1 von IfW-Connection
33+
# In case we run this configuration, we are forwarded from that menu to here and require
34+
# to enter the hostname in addition
35+
if ((Test-IcingaForWindowsManagementConsoleContinue) -And $JumpToSummary -eq $FALSE) {
36+
$global:Icinga.InstallWizard.NextCommand = 'Show-IcingaForWindowsInstallerMenuSelectHostname';
37+
}
3038
}
3139

3240
Set-Alias -Name 'IfW-CAFile' -Value 'Show-IcingaForWindowsInstallerMenuEnterIcingaCAFile';

lib/core/installer/menu/installation/certificate/SelectCertificate.psm1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ function Show-IcingaForWindowsInstallerMenuSelectCertificate()
4949
break;
5050
};
5151
}
52+
53+
# By Default, we are not jumping to the Summary on this menu but will require this in case
54+
# we choose CAFile selection and are on the summary page, as then we do not want to be prompted
55+
# for the Hostname again and require to tell the CA menu, that we should directly move to the
56+
# summary page again
57+
$LastInput = Get-IcingaForWindowsManagementConsoleLastInput;
58+
59+
if ($LastInput -eq '2' -And $JumpToSummary) {
60+
$global:Icinga.InstallWizard.NextCommand = 'Show-IcingaForWindowsInstallerMenuEnterIcingaCAFile';
61+
$global:Icinga.InstallWizard.NextArguments = @{ 'JumpToSummary' = $TRUE; };
62+
}
5263
}
5364

5465
Set-Alias -Name 'IfW-Certificate' -Value 'Show-IcingaForWindowsInstallerMenuSelectCertificate';

lib/core/installer/menu/installation/icinga/SelectConnection.psm1

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ function Show-IcingaForWindowsInstallerMenuSelectConnection()
2020
},
2121
@{
2222
'Caption' = 'Connecting from parent system';
23-
'Command' = 'Show-IcingaForWindowsInstallerMenuSelectHostname';
24-
'Help' = 'Choose this option if the Icinga Agent should not or cannot connect to a parent Icinga node and only connections from a Master/Satellite are possible. This will open the Windows firewall for the chosen Icinga protocol port (default 5665). Certificate generation might require additional steps.';
23+
'Command' = 'Show-IcingaForWindowsInstallerMenuEnterIcingaCAFile';
24+
'Help' = 'Choose this option if the Icinga Agent should not or cannot connect to a parent Icinga node and only connections from a Master/Satellite are possible. This will open the Windows firewall for the chosen Icinga protocol port (default 5665). Certificate generation requires to specify the location of the Icinga ca.crt, which is required to complete the setup process.';
2525
},
2626
@{
2727
'Caption' = 'Connecting from both systems';
@@ -39,6 +39,22 @@ function Show-IcingaForWindowsInstallerMenuSelectConnection()
3939
-ConfigElement `
4040
-Automated:$Automated `
4141
-Advanced:$Advanced;
42+
43+
# If we choose option 1 "Connecting from parent system", we require to ask the user for the
44+
# location of the ca.crt, as otherwise the api feature will not be enabled. This section will
45+
# ensure we are forwarded to the proper menu later on and certain options are defined for our
46+
# certificate handling
47+
$LastInput = Get-IcingaForWindowsManagementConsoleLastInput;
48+
49+
if ([string]::IsNullOrEmpty($LastInput) -eq $FALSE -and $LastInput -ne '1') {
50+
# Remove the set hostname in case we choose a different option
51+
Add-IcingaForWindowsInstallerConfigEntry -Selection '0' -OverwriteMenu 'Show-IcingaForWindowsInstallerMenuSelectCertificate' -Advanced;
52+
Remove-IcingaForWindowsInstallerConfigEntry -Menu 'Show-IcingaForWindowsInstallerMenuEnterIcingaCAFile';
53+
} elseif ($LastInput -eq '1') {
54+
Add-IcingaForWindowsInstallerConfigEntry -Selection '2' -OverwriteMenu 'Show-IcingaForWindowsInstallerMenuSelectCertificate' -Advanced;
55+
$global:Icinga.InstallWizard.NextCommand = 'Show-IcingaForWindowsInstallerMenuEnterIcingaCAFile';
56+
$global:Icinga.InstallWizard.NextArguments = @{ 'JumpToSummary' = $JumpToSummary; };
57+
}
4258
}
4359

4460
Set-Alias -Name 'IfW-Connection' -Value 'Show-IcingaForWindowsInstallerMenuSelectConnection';

0 commit comments

Comments
 (0)