Icinga PowerShell Framework - Using hostname as display_name (without domain)

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. :wink:

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!

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;