mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 15:19:58 -05:00
Improved Agent Install Wizard for global zone config
This commit is contained in:
parent
409d532ae0
commit
0c5bcf9338
1 changed files with 39 additions and 4 deletions
|
|
@ -6,6 +6,8 @@ function Start-IcingaAgentInstallWizard()
|
||||||
[switch]$AutoUseHostname = $FALSE,
|
[switch]$AutoUseHostname = $FALSE,
|
||||||
[switch]$LowerCase = $FALSE,
|
[switch]$LowerCase = $FALSE,
|
||||||
[switch]$UpperCase = $FALSE,
|
[switch]$UpperCase = $FALSE,
|
||||||
|
$AddDirectorGlobal = $null,
|
||||||
|
$AddGlobalTemplates = $null,
|
||||||
[string]$PackageSource,
|
[string]$PackageSource,
|
||||||
[string]$AgentVersion,
|
[string]$AgentVersion,
|
||||||
[switch]$AllowVersionChanges = $FALSE,
|
[switch]$AllowVersionChanges = $FALSE,
|
||||||
|
|
@ -24,6 +26,7 @@ function Start-IcingaAgentInstallWizard()
|
||||||
);
|
);
|
||||||
|
|
||||||
[array]$InstallerArguments = @();
|
[array]$InstallerArguments = @();
|
||||||
|
[array]$GlobalZoneConfig = @();
|
||||||
|
|
||||||
if ([string]::IsNullOrEmpty($Hostname) -And $AutoUseFQDN -eq $FALSE -And $AutoUseHostname -eq $FALSE) {
|
if ([string]::IsNullOrEmpty($Hostname) -And $AutoUseFQDN -eq $FALSE -And $AutoUseHostname -eq $FALSE) {
|
||||||
if ((Get-IcingaAgentInstallerAnswerInput -Prompt 'Do you want to manually specify a hostname?' -Default 'n').result -eq 1) {
|
if ((Get-IcingaAgentInstallerAnswerInput -Prompt 'Do you want to manually specify a hostname?' -Default 'n').result -eq 1) {
|
||||||
|
|
@ -136,14 +139,44 @@ function Start-IcingaAgentInstallWizard()
|
||||||
$InstallerArguments += "-ParentZone $ParentZone";
|
$InstallerArguments += "-ParentZone $ParentZone";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($null -eq $AddDirectorGlobal) {
|
||||||
|
if ((Get-IcingaAgentInstallerAnswerInput -Prompt 'Do you want to add the global zone "director-global"?' -Default 'y').result -eq 1) {
|
||||||
|
$AddDirectorGlobal = $TRUE;
|
||||||
|
} else {
|
||||||
|
$AddDirectorGlobal = $FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$InstallerArguments += ("-AddDirectorGlobal $AddDirectorGlobal");
|
||||||
|
if ($AddDirectorGlobal) {
|
||||||
|
$GlobalZoneConfig += 'director-global';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($null -eq $AddGlobalTemplates) {
|
||||||
|
if ((Get-IcingaAgentInstallerAnswerInput -Prompt 'Do you want to add the global zone "global-templates"?' -Default 'y').result -eq 1) {
|
||||||
|
$AddGlobalTemplates = $TRUE;
|
||||||
|
} else {
|
||||||
|
$AddGlobalTemplates = $FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$InstallerArguments += ("-AddGlobalTemplates $AddGlobalTemplates");
|
||||||
|
if ($AddGlobalTemplates) {
|
||||||
|
$GlobalZoneConfig += 'global-templates';
|
||||||
|
}
|
||||||
|
|
||||||
if ($null -eq $GlobalZones) {
|
if ($null -eq $GlobalZones) {
|
||||||
if ((Get-IcingaAgentInstallerAnswerInput -Prompt 'Do you want to add additional global zones, besides "director-global" and "global-templates"?' -Default 'n').result -eq 0) {
|
if ((Get-IcingaAgentInstallerAnswerInput -Prompt 'Do you want to add custom global zones?' -Default 'n').result -eq 0) {
|
||||||
$ArrayString = (Get-IcingaAgentInstallerAnswerInput -Prompt 'Please specify your additional zones seperated by ","' -Default 'v').answer;
|
$ArrayString = (Get-IcingaAgentInstallerAnswerInput -Prompt 'Please specify your additional zones seperated by ","' -Default 'v').answer;
|
||||||
$GlobalZones = ($ArrayString.Replace(' ', '')).Split(',');
|
$GlobalZones = ($ArrayString.Replace(' ', '')).Split(',')
|
||||||
|
$GlobalZoneConfig += $GlobalZones;
|
||||||
$InstallerArguments += ("-GlobalZones " + ([string]::Join(',', $GlobalZones)));
|
$InstallerArguments += ("-GlobalZones " + ([string]::Join(',', $GlobalZones)));
|
||||||
} else {
|
} else {
|
||||||
$GlobalZones = @();
|
$GlobalZones = @();
|
||||||
|
$InstallerArguments += ("-GlobalZones @()");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$GlobalZoneConfig += $GlobalZones;
|
||||||
}
|
}
|
||||||
|
|
||||||
[bool]$CanConnectToParent = $FALSE;
|
[bool]$CanConnectToParent = $FALSE;
|
||||||
|
|
@ -170,10 +203,12 @@ function Start-IcingaAgentInstallWizard()
|
||||||
$CAPort = 5665;
|
$CAPort = 5665;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ([string]::IsNullOrEmpty($Ticket)) {
|
if ($null -eq $Ticket) {
|
||||||
if ((Get-IcingaAgentInstallerAnswerInput -Prompt 'Do you have a Icinga Ticket available to sign your certificate?' -Default 'y').result -eq 1) {
|
if ((Get-IcingaAgentInstallerAnswerInput -Prompt 'Do you have a Icinga Ticket available to sign your certificate?' -Default 'y').result -eq 1) {
|
||||||
$Ticket = (Get-IcingaAgentInstallerAnswerInput -Prompt 'Please enter your Icinga Ticket' -Default 'v').answer;
|
$Ticket = (Get-IcingaAgentInstallerAnswerInput -Prompt 'Please enter your Icinga Ticket' -Default 'v').answer;
|
||||||
$InstallerArguments += "-Ticket $Ticket";
|
$InstallerArguments += "-Ticket $Ticket";
|
||||||
|
} else {
|
||||||
|
$InstallerArguments += "-Ticket ''";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -210,7 +245,7 @@ function Start-IcingaAgentInstallWizard()
|
||||||
Install-IcingaAgentBaseFeatures;
|
Install-IcingaAgentBaseFeatures;
|
||||||
Install-IcingaAgentCertificates -Hostname $Hostname -Endpoint $CAEndpoint -Port $CAPort -CACert $CAFile -Ticket $Ticket | Out-Null;
|
Install-IcingaAgentCertificates -Hostname $Hostname -Endpoint $CAEndpoint -Port $CAPort -CACert $CAFile -Ticket $Ticket | Out-Null;
|
||||||
Write-IcingaAgentApiConfig -Port $CAPort;
|
Write-IcingaAgentApiConfig -Port $CAPort;
|
||||||
Write-IcingaAgentZonesConfig -Endpoints $Endpoints -EndpointConnections $EndpointConnections -ParentZone $ParentZone -GlobalZones $GlobalZones -Hostname $Hostname;
|
Write-IcingaAgentZonesConfig -Endpoints $Endpoints -EndpointConnections $EndpointConnections -ParentZone $ParentZone -GlobalZones $GlobalZoneConfig -Hostname $Hostname;
|
||||||
Test-IcingaAgent;
|
Test-IcingaAgent;
|
||||||
Restart-Service icinga2;
|
Restart-Service icinga2;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue