Skip to content

Commit aa6d324

Browse files
authored
Merge branch 'master' into ifw_api_arguments
2 parents a11e640 + 3bef2b4 commit aa6d324

18 files changed

+253
-64
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
[![PowerShell Version](https://img.shields.io/badge/PowerShell-5.1-777BB4?logo=PowerSHell)](https://learn.microsoft.com/en-US/powershell/scripting/install/installing-powershell-on-windows?view=powershell-5.1)
2+
[![GitHub Tag](https://img.shields.io/github/tag/Icinga/icinga-powershell-framework.svg)](https://github.com/Icinga/icinga-powershell-framework/releases/latest)
3+
[![GitHub Issues](https://img.shields.io/github/issues-search?query=repo%3Aicinga%2Ficinga-powershell-framework%20is%3Aopen%20is%3Aissue&label=Issues&color=red
4+
)](https://github.com/Icinga/icinga-powershell-framework/issues)
5+
[![GitHub Pull Requests](https://img.shields.io/github/issues-search?query=repo%3Aicinga%2Ficinga-powershell-framework%20is%3Aopen%20is%3Apr&label=Pull%20Requests&color=green
6+
)](https://github.com/Icinga/icinga-powershell-framework/pulls)
7+
18
Icinga PowerShell Framework
29
==============
310

doc/100-General/10-Changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1818
* [#615](https://github.com/Icinga/icinga-powershell-framework/issues/615) Fixes the framework migration tasks which fails in case multiple versions of the framework are installed, printing warnings in case there is
1919
* [#617](https://github.com/Icinga/icinga-powershell-framework/issues/617) Fixes failing calls for plugins which use a switch argument like `-NoPerfData`, which is followed directly by the `-ThresholdInterval` argument
2020
* [#621](https://github.com/Icinga/icinga-powershell-framework/pull/621) Fixes `-ThresholdInterval` key detection on newer systems
21+
* [#645](https://github.com/Icinga/icinga-powershell-framework/pull/645) Fixes error and exception handling while using API-Checks, which now will in most cases always return a proper check-result object and also abort while running into plugin execution errors, in case a server is not reachable by the time sync plugin for example
2122

2223
### Enhancements
2324

25+
* [#544](https://github.com/Icinga/icinga-powershell-framework/issues/544) Adds support to configure the Icinga Director JSON string for registering hosts via self-service API
2426
* [#619](https://github.com/Icinga/icinga-powershell-framework/pull/619) Adds feature to securely read enum provider values with new function `Get-IcingaProviderEnumData`
2527
* [#623](https://github.com/Icinga/icinga-powershell-framework/issues/623) Adds support to provide the Icinga service user written as `user@domain`
2628
* [#633](https://github.com/Icinga/icinga-powershell-framework/pull/633) Adds support for Icinga 2.14.0 native Icinga for Windows API communication
29+
* [#635](https://github.com/Icinga/icinga-powershell-framework/pull/635) Adds support for `Write-IcingaAgentApiConfig` function to configure the Icinga Agent TLS cipher list setting by new argument `-CipherList`
30+
* [#640](https://github.com/Icinga/icinga-powershell-framework/issues/640) Adds support to set the flag `-NoSSLValidation` for Cmdlets `icinga` and `Install-Icinga`, to ignore errors on self-signed certificates within the environment
31+
* [#643](https://github.com/Icinga/icinga-powershell-framework/pull/643) Adds support for `-RebuildCache` flag on `icinga` cmd to rebuild component cache as well
32+
* [#644](https://github.com/Icinga/icinga-powershell-framework/pull/644) Adds progress bar output to repository interaction (sync, update, new) instead of plain text output
2733

2834
## 1.10.1 (2022-12-20)
2935

doc/110-Installation/01-Getting-Started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Icinga for Windows provides tools and functionality to entirely manage itself. T
66

77
* Windows 2012 R2 or later
88
* PowerShell Version 4.0 or later
9-
* [Execution Policies](https://docs.microsoft.com/de-de/powershell/module/microsoft.powershell.core/about/about_execution_policies) allowing module/script execution
9+
* [Execution Policies](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies) allowing module/script execution
1010
* Access to [packages.icinga.com](https://packages.icinga.com) at least from one location
1111

1212
## Installation Dependencies

doc/130-JEA/01-JEA-Profiles.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Starting with Icinga for Windows v1.6.0, we are supporting JEA profiles and provide all required tools to build a profile based on installed Icinga for Windows components.
44

5-
JEA stands for "Just Enough Administration" and you can read more about it on the [Microsoft Docs](https://docs.microsoft.com/de-de/powershell/scripting/learn/remoting/jea/overview).
5+
JEA stands for "Just Enough Administration" and you can read more about it on the [Microsoft Docs](https://docs.microsoft.com/en-us/powershell/scripting/learn/remoting/jea/overview).
66

77
In short, JEA allows you to limit the access to certain Cmdlets, Functions and Binaries on the system. In addition, you can grant additional privileges to users to perform tasks, which are permitted to Administrators only in general.
88

icinga-powershell-framework.psm1

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,13 @@ function Invoke-IcingaCommand()
243243
[CmdletBinding()]
244244
param (
245245
$ScriptBlock,
246-
[switch]$SkipHeader = $FALSE,
247-
[switch]$Manage = $FALSE, # Only for backwards compatibility, has no use at all
248-
[switch]$Shell = $FALSE,
249-
[switch]$RebuildCache = $FALSE,
250-
[switch]$DeveloperMode = $FALSE,
251-
[array]$ArgumentList = @()
246+
[switch]$SkipHeader = $FALSE,
247+
[switch]$Manage = $FALSE, # Only for backwards compatibility, has no use at all
248+
[switch]$Shell = $FALSE,
249+
[switch]$NoSSLValidation = $FALSE,
250+
[switch]$RebuildCache = $FALSE,
251+
[switch]$DeveloperMode = $FALSE,
252+
[array]$ArgumentList = @()
252253
);
253254

254255
Import-LocalizedData `
@@ -280,6 +281,7 @@ function Invoke-IcingaCommand()
280281
}
281282

282283
if ($RebuildCache -Or $DeveloperMode) {
284+
Copy-IcingaFrameworkCacheTemplate;
283285
Write-IcingaFrameworkCodeCache -DeveloperMode:$DeveloperMode;
284286
}
285287

@@ -304,10 +306,19 @@ function Invoke-IcingaCommand()
304306
$Shell = $args[3];
305307
$IcingaShellArgs = $args[4];
306308
$DeveloperMode = $args[5];
309+
$NoSSLValidation = $args[6];
307310

308311
# Load our Icinga Framework
309312
Use-Icinga;
310313

314+
# Always ensure we use the proper TLS Version
315+
Set-IcingaTLSVersion;
316+
317+
# Ignore SSL validation in case we set the flag
318+
if ($NoSSLValidation) {
319+
Enable-IcingaUntrustedCertificateValidation;
320+
}
321+
311322
if ($DeveloperMode) {
312323
$Global:Icinga.Protected.DeveloperMode = $TRUE;
313324
Copy-IcingaFrameworkCacheTemplate;
@@ -336,7 +347,7 @@ function Invoke-IcingaCommand()
336347
return "> "
337348
}
338349

339-
} -Args $ScriptBlock, $PSScriptRoot, $IcingaFrameworkData.PrivateData.Version, ([bool]$Shell), $ArgumentList, ([bool]$DeveloperMode);
350+
} -Args $ScriptBlock, $PSScriptRoot, $IcingaFrameworkData.PrivateData.Version, ([bool]$Shell), $ArgumentList, ([bool]$DeveloperMode), ([bool]$NoSSLValidation);
340351

341352
# In case we close the newly created PowerShell, ensure we set the script root back to the Framework folder
342353
if (Test-Path $PSScriptRoot) {
@@ -349,13 +360,14 @@ function Invoke-IcingaCommand()
349360

350361
# Use the same arguments again to open the IMC
351362
$IMCReopenArguments = @{
352-
'ScriptBlock' = $ScriptBlock;
353-
'SkipHeader' = $SkipHeader;
354-
'Manage' = $Manage;
355-
'Shell' = $Shell;
356-
'RebuildCache' = $RebuildCache;
357-
'DeveloperMode' = $DeveloperMode;
358-
'ArgumentList' = $ArgumentList;
363+
'ScriptBlock' = $ScriptBlock;
364+
'SkipHeader' = $SkipHeader;
365+
'Manage' = $Manage;
366+
'Shell' = $Shell;
367+
'NoSSLValidation' = $NoSSLValidation;
368+
'RebuildCache' = $RebuildCache;
369+
'DeveloperMode' = $DeveloperMode;
370+
'ArgumentList' = $ArgumentList;
359371
};
360372

361373
Invoke-IcingaCommand @IMCReopenArguments;

lib/apis/Register-IcingaDirectorSelfServiceHost.psm1

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,26 @@ function Register-IcingaDirectorSelfServiceHost()
6161
}
6262
}
6363

64-
$Interface = Get-IcingaNetworkInterface $Endpoint;
65-
$DirectorConfigJson = [string]::Format('{0} "address":"{2}" {1}', '{', '}', $Interface);
64+
$Interface = Get-IcingaNetworkInterface $Endpoint;
65+
66+
if ($null -eq $Global:Icinga.InstallWizard.DirectorSelfServiceConfig) {
67+
$DirectorConfigJson = [string]::Format('{{ "address": "{0}" }}', $Interface);
68+
} else {
69+
try {
70+
$DirectorConfigJson = ConvertTo-Json -InputObject $Global:Icinga.InstallWizard.DirectorSelfServiceConfig -Compress -ErrorAction Stop;
71+
$DirectorConfigJson = $DirectorConfigJson.Replace('$ifw.hostaddress$', $Interface);
72+
$DirectorConfigJson = $DirectorConfigJson.Replace('$ifw.hostname.tolower$', (Get-IcingaHostname -AutoUseHostname 1 -LowerCase 1));
73+
$DirectorConfigJson = $DirectorConfigJson.Replace('$ifw.hostname.toupper$', (Get-IcingaHostname -AutoUseHostname 1 -UpperCase 1));
74+
$DirectorConfigJson = $DirectorConfigJson.Replace('$ifw.hostname$', (Get-IcingaHostname -AutoUseHostname 1));
75+
$DirectorConfigJson = $DirectorConfigJson.Replace('$ifw.hostfqdn.tolower$', (Get-IcingaHostname -AutoUseFQDN 1 -LowerCase 1));
76+
$DirectorConfigJson = $DirectorConfigJson.Replace('$ifw.hostfqdn.toupper$', (Get-IcingaHostname -AutoUseFQDN 1 -UpperCase 1));
77+
$DirectorConfigJson = $DirectorConfigJson.Replace('$ifw.hostfqdn$', (Get-IcingaHostname -AutoUseFQDN 1));
78+
} catch {
79+
# Fallback to default
80+
Write-IcingaConsosoleError 'Failed to deserialize your custom Icinga Director Self-Service configuration. Using Icinga for Windows defaults.'
81+
$DirectorConfigJson = [string]::Format('{{ "address": "{0}" }}', $Interface);
82+
}
83+
}
6684

6785
$EndpointUrl = Join-WebPath -Path $DirectorUrl -ChildPath ([string]::Format('/self-service/register-host?name={0}&key={1}', $Hostname, $ApiKey));
6886

lib/core/icingaagent/writers/Write-IcingaAgentApiConfig.psm1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
function Write-IcingaAgentApiConfig()
22
{
3-
param(
4-
[int]$Port = 5665
3+
param (
4+
[int]$Port = 5665,
5+
[string]$CipherList = $null
56
);
67

78
[string]$ApiConf = '';
@@ -11,6 +12,9 @@ function Write-IcingaAgentApiConfig()
1112
$ApiConf = [string]::Format('{0} accept_config = true;{1}', $ApiConf, "`r`n");
1213
$ApiConf = [string]::Format('{0} bind_host = "::";{1}', $ApiConf, "`r`n");
1314
$ApiConf = [string]::Format('{0} bind_port = {1};{2}', $ApiConf, $Port, "`r`n");
15+
if ([string]::IsNullOrEmpty($CipherList) -eq $FALSE) {
16+
$ApiConf = [string]::Format('{0} cipher_list = "{1}";{2}', $ApiConf, $CipherList, "`r`n");
17+
}
1418
$ApiConf = [string]::Format('{0}{1}{2}{2}', $ApiConf, '}', "`r`n");
1519

1620
$ApiConf = $ApiConf.Substring(0, $ApiConf.Length - 4);

lib/core/installer/Install-Icinga.psm1

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,55 @@
11
function Install-Icinga()
22
{
33
param (
4-
[string]$InstallCommand = $null,
5-
[string]$InstallFile = ''
4+
[string]$InstallCommand = $null,
5+
[string]$InstallFile = '',
6+
[switch]$NoSSLValidation = $FALSE
67
);
78

89
if ($null -eq $global:Icinga) {
910
$global:Icinga = @{ };
1011
}
1112

13+
# Always ensure we use the proper TLS Version
14+
Set-IcingaTLSVersion;
15+
16+
# Ignore SSL validation in case we set the flag
17+
if ($NoSSLValidation) {
18+
Enable-IcingaUntrustedCertificateValidation;
19+
}
20+
1221
if ($global:Icinga.ContainsKey('InstallWizard') -eq $FALSE) {
1322
$global:Icinga.Add(
1423
'InstallWizard', @{
15-
'AdminShell' = (Test-AdministrativeShell);
16-
'LastInput' = '';
17-
'LastNotice' = '';
18-
'LastWarning' = @();
19-
'LastError' = @();
20-
'DirectorError' = '';
21-
'HeaderPreview' = '';
22-
'DirectorSelfService' = $FALSE;
23-
'DirectorRegisteredHost' = $FALSE;
24-
'DirectorInstallError' = $FALSE;
25-
'LastParent' = [System.Collections.ArrayList]@();
26-
'LastValues' = @();
27-
'DisabledEntries' = @{ };
28-
'Config' = @{ };
29-
'ConfigSwap' = @{ };
30-
'ParentConfig' = $null;
31-
'Menu' = 'Install-Icinga';
32-
'NextCommand' = '';
33-
'NextArguments' = $null;
34-
'HeaderSelection' = $null;
35-
'DisplayAdvanced' = $FALSE;
36-
'ShowAdvanced' = $FALSE;
37-
'ShowHelp' = $FALSE;
38-
'ShowCommand' = $FALSE;
39-
'DeleteValues' = $FALSE;
40-
'HeaderPrint' = $FALSE;
41-
'JumpToSummary' = $FALSE;
42-
'Closing' = $FALSE;
24+
'AdminShell' = (Test-AdministrativeShell);
25+
'LastInput' = '';
26+
'LastNotice' = '';
27+
'LastWarning' = @();
28+
'LastError' = @();
29+
'DirectorError' = '';
30+
'HeaderPreview' = '';
31+
'DirectorSelfServiceConfig' = $null;
32+
'DirectorSelfService' = $FALSE;
33+
'DirectorRegisteredHost' = $FALSE;
34+
'DirectorInstallError' = $FALSE;
35+
'LastParent' = [System.Collections.ArrayList]@();
36+
'LastValues' = @();
37+
'DisabledEntries' = @{ };
38+
'Config' = @{ };
39+
'ConfigSwap' = @{ };
40+
'ParentConfig' = $null;
41+
'Menu' = 'Install-Icinga';
42+
'NextCommand' = '';
43+
'NextArguments' = $null;
44+
'HeaderSelection' = $null;
45+
'DisplayAdvanced' = $FALSE;
46+
'ShowAdvanced' = $FALSE;
47+
'ShowHelp' = $FALSE;
48+
'ShowCommand' = $FALSE;
49+
'DeleteValues' = $FALSE;
50+
'HeaderPrint' = $FALSE;
51+
'JumpToSummary' = $FALSE;
52+
'Closing' = $FALSE;
4353
}
4454
);
4555
} else {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function Add-IcingaForWindowsInstallationAdvancedEntries()
3131
Show-IcingaForWindowsInstallationMenuEnterIcingaCAServer -Automated -Advanced;
3232
Show-IcingaForWindowsInstallerMenuSelectInstallApiChecks -Automated -Advanced;
3333
Show-IcingaForWindowsInstallerMenuSelectServiceRecovery -Automated -Advanced;
34+
Show-IcingaForWindowsManagementConsoleInstallationEnterDirectorSelfServiceConfig -Automated -Advanced;
3435

3536
Enable-IcingaFrameworkConsoleOutput;
3637

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
function Show-IcingaForWindowsManagementConsoleInstallationEnterDirectorSelfServiceConfig()
2+
{
3+
param (
4+
[array]$Value = @(),
5+
[string]$DefaultInput = 'c',
6+
[switch]$JumpToSummary = $FALSE,
7+
[switch]$Automated = $FALSE,
8+
[switch]$Advanced = $FALSE
9+
);
10+
11+
# Ensure we simply set the global variable for the Config in case we run in automation mode
12+
if ($Automated) {
13+
if ($null -ne $Value -And $null -ne $Value[0]) {
14+
$Global:Icinga.InstallWizard.DirectorSelfServiceConfig = ConvertFrom-Json -InputObject $Value[0] -ErrorAction Stop;
15+
return;
16+
}
17+
}
18+
19+
# Set the default if no value ist set
20+
if ($Value -IsNot [array] -Or $null -eq $Value -or $Value.Count -eq 0) {
21+
$Value.Clear();
22+
if ($null -eq $Global:Icinga.InstallWizard.DirectorSelfServiceConfig) {
23+
$Value += '{ "address": "$ifw.hostaddress$" }';
24+
} else {
25+
$Value += ConvertTo-Json -InputObject $Global:Icinga.InstallWizard.DirectorSelfServiceConfig -Depth 100 -Compress;
26+
}
27+
}
28+
29+
Show-IcingaForWindowsInstallerMenu `
30+
-Header 'You can update the Icinga Director Self-Service config in this section. USE WITH CARE!' `
31+
-Entries @(
32+
@{
33+
'Command' = 'Show-IcingaForWindowsInstallerConfigurationSummary';
34+
'Help' = 'This is the configuration JSON-Object for the Icinga Director Self-Service API. You can set a custom IP-Address or define the display name of an object with "display_name" as key. Use this methid with caution! Not all configuration elements in general possible are accessible by using the Self-Service keys.';
35+
}
36+
) `
37+
-DefaultIndex $DefaultInput `
38+
-AddConfig `
39+
-ConfigLimit 1 `
40+
-DefaultValues @( $Value ) `
41+
-MandatoryValue `
42+
-JumpToSummary:$JumpToSummary `
43+
-ConfigElement `
44+
-Automated:$Automated `
45+
-Advanced:$Advanced;
46+
47+
# Fetch the current JSON-String inserted by the user
48+
[string]$ConfigString = Get-IcingaForWindowsInstallerValuesFromStep;
49+
50+
if ([string]::IsNullOrEmpty($ConfigString) -eq $FALSE) {
51+
try {
52+
# Validate that our JSON is correct
53+
$Global:Icinga.InstallWizard.DirectorSelfServiceConfig = ConvertFrom-Json -InputObject $ConfigString -ErrorAction Stop;
54+
} catch {
55+
# Set some defaults to ensure we don't break the installer
56+
Write-IcingaConsoleError ([string]::Format('The provided Icinga Director Self Service configuration "{0}" does not appear to be a valid JSON-String. E.g.: {{ "address": "$ifw.hostaddress$" }} without leading and ending "" before and after {{ }}', $ConfigString));
57+
$Global:Icinga.InstallWizard.DirectorSelfServiceConfig = $null;
58+
Set-IcingaForWindowsInstallerValuesFromStep -Values @( '{ }' );
59+
}
60+
} else {
61+
$Global:Icinga.InstallWizard.DirectorSelfServiceConfig = $null;
62+
}
63+
}
64+
65+
Set-Alias -Name 'IfW-DirectorSelfServiceConfig' -Value 'Show-IcingaForWindowsManagementConsoleInstallationEnterDirectorSelfServiceConfig';

0 commit comments

Comments
 (0)