Icinga for Windows: Migrate from Kickstart script to IfW Installer

Hello there.

I’m currently trying to figure out how to migrate our Icinga installation procedure for Windows VMs from the old and deprecated (but pretty easy to use) Kickstart script to the new installation procedure.

Currently we have the following installation being executed via Ansible:
(excerpt)

[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11";
$ProgressPreference = "SilentlyContinue";
$global:IcingaFrameworkKickstartSource = 'https://raw.githubusercontent.com/Icinga/icinga-powershell-kickstart/master/script/icinga-powershell-kickstart.ps1';
$Script = (Invoke-WebRequest -UseBasicParsing -Uri $global:IcingaFrameworkKickstartSource).Content;
$Script += "`r`n`r`n Start-IcingaFrameworkWizard -RepositoryUrl 'https://github.com/Icinga/icinga-powershell-framework/archive/v$frameworkversion.zip' 
	-ModuleDirectory 'C:\Program Files\WindowsPowerShell\Modules' -AllowUpdate $TRUE -SkipWizard $TRUE;";
Invoke-Command -ScriptBlock ([Scriptblock]::Create($Script));
$pluginurl = "https://github.com/Icinga/icinga-powershell-plugins/archive/refs/tags/v" + $pluginsversion + ".zip"
$serviceurl = "https://github.com/Icinga/icinga-powershell-service/releases/download/v" + $serviceversion + "/icinga-service-v" + $serviceversion + ".zip"
Use-Icinga
Start-IcingaAgentInstallWizard -UseDirectorSelfService 0 -AutoUseFQDN 0 -AutoUseHostname 1 -LowerCase 1 -UpperCase 0 -PackageSource 'https://packages.icinga.com/windows/' 
	-AllowVersionChanges 1 -UpdateAgent 1 -AgentVersion $agentversion -Endpoints $endpoints -CAPort $caport -AcceptConnections 0 -AddFirewallRule 1 -ConvertEndpointIPConfig 1 
	-EndpointConnections $endpointConnections -ParentZone $parentZone -AddDirectorGlobal 1 -AddGlobalTemplates 1 -GlobalZones $globalZones -CAEndpoint $caendpoint -EmptyTicket 0 
	-Ticket $ticket -ServiceUser $serviceuser -InstallFrameworkPlugins 1 -PluginsUrl $pluginurl -InstallFrameworkService 1 -FrameworkServiceUrl $serviceurl 
	-ServiceDirectory 'C:\Program Files\icinga-framework-service\' -ServiceBin 'C:\Program Files\icinga-framework-service\icinga-service.exe' -RunInstaller

Now I wanted to convert this to the currently proposed way from the docs:
https://icinga.com/docs/icinga-for-windows/latest/doc/110-Installation/01-Getting-Started/

When running

[Net.ServicePointManager]::SecurityProtocol = 'tls12, tls11';
$ProgressPreference                         = 'SilentlyContinue';
[string]$ScriptFile                         = 'C:\Users\Public\IcingaForWindows.ps1';

Invoke-WebRequest `
    -UseBasicParsing `
    -Uri 'https://packages.icinga.com/IcingaForWindows/IcingaForWindows.ps1' `
    -OutFile $ScriptFile;

& $ScriptFile -ModuleDirectory 'C:\Program Files\WindowsPowerShell\Modules\' -SkipWizard;

it simply installs the Framework in the latest version, which I don’t want.
I need to specify the versions for all the components.

Sadly the documentation is lacking information about the usage options of the -InstallCommand or the -AnswerFile parameters (or it is hidden somewhere^^).
I hope that I could use those to, at least, say what version the Framework should be installed in.
The other components (Agent, Plugins, Service) could then be installed with Install-IcingaComponent -Name ... -Version ... as far as I can see.
edit: well… or it doesn’t

PS C:\Windows\system32> Install-IcingaComponent -name plugins
[Error]: The component "plugins" was not found on stable channel with version "release"

PS C:\Windows\system32> Install-IcingaComponent -name plugin -version 1.8.0
[Error]: The component "plugin" was not found on stable channel with version "1.8.0"

PS C:\Windows\system32> Install-IcingaComponent -name plugins -version "icinga-powershell-plugins-1.8.0"
[Error]: The component "plugins" was not found on stable channel with version "icinga-powershell-plugins-1.8.0"

PS C:\Windows\system32> Install-IcingaComponent -name plugins -version "icinga-powershell-plugins-1.8.0.zip"
[Error]: The component "plugins" was not found on stable channel with version "icinga-powershell-plugins-1.8.0.zip"

Anyone here already played around with the new installer and can give some hints/tips?
That would be greatly appreciated!

Cheers :slight_smile:

So I learned (:palm_tree: :v: ) that the repository has to be specified explicitly.
The docs state this, if the installation was not done via the IMC, which I didn’t take in apparently…

edit:
Though looking at the script (https://packages.icinga.com/IcingaForWindows/IcingaForWindows.ps1) I see that the $RepositoryURL is set as a default for both the script and the included function. So, imo, the repository should be set, which it clearly isn’t.

But this doesn’t really help for the framework itself.
I don’t think the intended way would be installing the framework in the most recent version and then use Install-IcingaComponente -Name framework -version x.y.z to downgrade the framework to the desired version.

edit2:
These two lines look like they are responsible for always using the latest version.

$KickstartPackage = $RepoData.Packages.Kickstart | Sort-Object Version -Descending | Select-Object -First 1;
$FrameworkPackage = $RepoData.Packages.Framework | Sort-Object Version -Descending | Select-Object -First 1;

Ping @cstein:
The repo default not being set looks like a bug to me and a parameter to chose a specific framework version, I think, would be quite easy to implement

param (
    [string]$IcingaRepository = 'https://packages.icinga.com/IcingaForWindows/stable/ifw.repo.json',
    [string]$ModuleDirectory  = $null,
    [string]$AnswerFile       = '',
    [string]$InstallCommand   = '',
    [switch]$AllowUpdate      = $FALSE,
    [switch]$SkipWizard       = $FALSE,
    [string]$FrameworkVersion = $null
);

...
<line 112>
if ($FrameworkVersion -ne $null -and $FrameworkVersion -match '^(\d+\.)?(\d+\.)?(\*|\d+)$'){
        $FrameworkPackage = $RepoData.Packages.Framework | Where-Object Version -Match $FrameworkVersion
    }
    else{
        $FrameworkPackage = $RepoData.Packages.Framework | Sort-Object Version -Descending | Select-Object -First 1;
    }
<line 119>
...

Install-IcingaKickstart `
	-IcingaRepository $IcingaRepository `
	-ModuleDirectory $ModuleDirectory `
	-AnswerFile $AnswerFile `
	-InstallCommand $InstallCommand `
	-AllowUpdate:$AllowUpdate `
	-SkipWizard:$SkipWizard `
    -FrameworkVersion:$FrameworkVersion;

If you don’t dismiss both as not needed/works as intended, I would open a bug & feature issue on github :slight_smile:

1 Like

So for the repository not being used I have honestly no idea at the moment. This should always be the default. Having a flag to install a certain Framework version should be doable.

Thank you for the issues: IcingaForWindows.ps1: Repository not set although it is given to the script as a default · Issue #510 · Icinga/icinga-powershell-framework (github.com)

and

IcingaForWindows.ps1: Parameter to install specific framework version · Issue #509 · Icinga/icinga-powershell-framework (github.com)

I will have a look on boh.

1 Like