AlexR
November 17, 2020, 9:24am
1
Hi Everybody!
We’re currently migrating our Icinga2 Agent installation package from “Icinga2 PowerShell Module” to “Icinga PowerShell Framework” (aka “Icinga for Windows”).
Using the “PowerShell Plugin” to register the new host with Icinga Director, the display name (display_name) was always set to be the hostname (without the domain part).
With “PowerShell Framework” the field “display_name” is empty (which leads to display the FQDN).
I’m wondering how to manage getting the hostname back as display_name via “PowerShell Framework”.
Versions:
IcingaWeb2 = 2.7.4
Director = 1.7.2
PowerShell Framework = 1.2.0
Thanks for your replies!
AlexR
P.S.: Prior to opening an issue on Github I wanted to ask here in the forum.
Hi There,
No need for a GitHub issue for this. We seem to have the setup that you would like to have take a look at this:
object Host "servername.internal" {
import "servers"
display_name = "servername"
Hope that gets you the result you would like!
AlexR
November 17, 2020, 2:02pm
3
Hi William, thanks for the reply.
It’s clear how to set the display_name in hosts config (or via Director).
Our problem occurs when using the “Icinga PowerShell Framework” installing the Icinga2 Agent and registering that new host via the Director API. It used to work with the PowerShell Module.
Hi,
I have been browsing for you here:
I cloned the repo and looked in it and found:
OverrideDirectorVars
This points me to:
.//lib/core/icingaagent/misc/Start-IcingaAgentInstallWizard.psm1
Perhaps you can get this to display a help
menu.
in the script there seem to be quite a few variables dedicated to hostname
Perhaps this is the variable you want to set:
131 $Result = Set-IcingaWizardArgument -DirectorArgs $DirectorArgs -WizardArg 'AutoUseHostname' -Value $AutoUseHostname -Default $FALSE -InstallerArguments $InstallerArguments;
132 $AutoUseHostname = $Result.Value;
It seems to ask you the question when you run it manually:
150 if ((Get-IcingaAgentInstallerAnswerInput -Prompt 'Do you want to specify the hostname manually?' -Default 'n').result -eq 1) {
151 $HostFQDN = Get-IcingaHostname -AutoUseFQDN 1 -AutoUseHostname 0 -LowerCase 1 -UpperCase 0;
152 if ((Get-IcingaAgentInstallerAnswerInput -Prompt ([string]::Format('Do you want to automatically fetch the hostname as FQDN? (Result: "{0}")', $HostFQDN)) -Default 'y').result -eq 1) {
153 $InstallerArguments += '-AutoUseFQDN 1';
154 $InstallerArguments += '-AutoUseHostname 0';
155 $AutoUseFQDN = $TRUE;
156 $AutoUseHostname = $FALSE;
AlexR
July 2, 2021, 8:21am
6
There is a feature request for PowerShell Framework on Github that was added to the v1.6.0 milestone.
opened 09:58AM - 25 Jun 21 UTC
Enhancement
---
We didn't find out how to set the host display_name to the local part (i.… e. without the domain part) when using _Start-IcingaAgentInstallWizard @AgentInstallParams -RunInstaller_.
See also:
* https://community.icinga.com/t/icinga-powershell-framework-using-hostname-as-display-name-without-domain/6074
* https://community.icinga.com/t/self-service-api-display-name/7593
## Expected Behavior
There should be a parameter for the host display name (display_name) to be set during registring of a new host with Icinga Director.
With the old PowerShell Module a display name was automatically set to the hostname (local part, without the domain part). All that without defining something manually.
## Current Behavior
There is no known option / parameter to define a display name in Icinga Director while registring via _Start-IcingaAgentInstallWizard_.
## Possible Solution
Make a parameter available to set _display_name_ when registring with Icinga Director.
## Steps to Reproduce (for bugs)
Install Icinga2 Agent with PowerShell Framework using _Start-IcingaAgentInstallWizard_
```
AgentInstallParams = @{
"SelfServiceAPIKey" = $SelfServiceAPIKey;
"UseDirectorSelfService" = 1;
"lowercase" = 1;
"DirectorUrl" = 'http://icingamaster1.domain.net/icingaweb2/director';
"OverrideDirectorVars" = 0;
"ConvertEndpointIPConfig" = 0;
"CAEndpoint" = "icingamaster1.domain.net";
"CAPort" = 5665;
"Ticket" = '';
"EmptyTicket" = 1;
"AgentVersion" = $appVersion;
"Endpoints" = $ParentEndpoints;
"ParentZone" = $ParentZone;
"AllowVersionChanges" = 1;
"InstallFrameworkPlugins" = 1;
"InstallFrameworkService" = 0;
"PluginsUrl" = "$dirFiles\icinga-powershell-plugins-1.3.0.zip";
"PackageSource" = "$dirFiles";
"ServiceUser" = "LocalSystem"
}
Start-IcingaAgentInstallWizard @AgentInstallParams -RunInstaller
```
## Your Environment
* PowerShell Version used (`$PSVersionTable.PSVersion`):
* 5.1.14409.1018
* 5.1.14393 .3866
* Operating System and version (`Get-IcingaWindowsInformation Win32_OperatingSystem | Select-Object Version, BuildNumber, Caption`):
* 6.3.9600 / 9600 / Microsoft Windows Server 2012 R2 Standard
* 10.0.14393 / 14393 / Microsoft Windows Server 2016 Datacenter
* Icinga2 Version 2.12.2-1 (HA)
* Icinga Web 2 Version 2.8.2
* Icinga Director Version 1.8.0