Icinga / icinga-powershell-framework

This PowerShell module will allow to fetch data from Windows hosts and use them for inventory and monitoring solutions. Together with the Icinga Web 2 module, a detailed overview of your Windows infrastructure will be drawn.
MIT License
78 stars 33 forks source link

IcingaForWindows.ps1: Repository not set although it is given to the script as a default #510

Open log1-c opened 2 years ago

log1-c commented 2 years ago

As experienced by me and stated in this thread (https://community.icinga.com/t/icinga-for-windows-migrate-from-kickstart-script-to-ifw-installer/9593) the installation of the Framework via the IcingaForWindows.ps1 script does the set the repository, although it is defined as a default value when the script is executed.

The means it is necessary to set the repository in another step, which, to be fair, is mentioned by the docs.

Nevertheless, looking at the script, this makes me wonder why the value of $IcingaRepository is not set.

LordHepipud commented 2 years ago

I have tried to reproduce the issue with the missing default repository and haven't found a way to get this issue to occur. In my environment, the default repository is always set and used.

At the moment I'm not sure on how to proceed in this matter.

log1-c commented 1 year ago

I finally have the time (a need ;)) to look at the whole IcingaForWindows/PowerShell framework stuff again.

I still experience the issue that there is no repository set when installing like the docs tells me.

PS C:\Windows\system32> & $ScriptFile -skipwizard;
[Notice]: PowerShell Execution-Policies are configured to run Scripts and/or Modules.
The following directories are available for installing PowerShell modules into:
[0]: C:\Users\Administrator\Documents\WindowsPowerShell\Modules
[1]: C:\Program Files\WindowsPowerShell\Modules (Recommended)
[2]: C:\Windows\system32\WindowsPowerShell\v1.0\Modules
[3]: C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell\
[4]: C:\Program Files\Microsoft Monitoring Agent\Agent\AzureAutomation\7.3.1455.3
Where do you want to install the Icinga PowerShell Framework into? ([0-4]) (Defaults: "1"):
[Notice]: Downloading Icinga PowerShell Framework into "C:\Users\ADMINI~1\AppData\Local\Temp\icinga-powershell-framework-zip"
[Notice]: Installing Icinga PowerShell Framework into "C:\Program Files\WindowsPowerShell\Modules"
[Notice]: Installing new Icinga PowerShell Framework version
[Notice]: Unblocking Icinga PowerShell Framework files
[Notice]: Applying pending migrations required for Icinga for Windows v1.8.0
[Notice]: Applying pending migrations required for Icinga for Windows v1.10.0
[Notice]: Applying pending migrations required for Icinga for Windows v1.10.1
[Notice]: Icinga PowerShell Framework seems to be successfully installed
[Notice]: To use the Icinga PowerShell Framework in the future, please initialize it by running the command "Use-Icinga" inside your PowerShell

((Get-Module -ListAvailable icinga-powershell-framework).Version).toString()
1.10.1

IMC: 2 -> 3 -> 2
*************************************************
**    Icinga for Windows Management Console    **
**    Copyright (c) 2022 Icinga GmbH | MIT     **
** User environment Q1ALE-WINTEST01\localadmin **
**     Icinga PowerShell Framework v1.10.1     **
*************************************************

There are no local configured Icinga Repositories

[x] Exit [c] Continue [h] Help [l] Commands [m] Main [p] Previous

IMC: 1 -> 0
*************************************************
**    Icinga for Windows Management Console    **
**    Copyright (c) 2022 Icinga GmbH | MIT     **
** User environment Q1ALE-WINTEST01\localadmin **
**     Icinga PowerShell Framework v1.10.1     **
*************************************************

There are no packages found for installation

Get-IcingaRepositories --> no Output

Install-IcingaComponent -name plugins
[Error]: The component "plugins" was not found on stable channel with version "release"

The same happens when explicitly setting the repository via the parameter to a local repository:

# install new icinga-powershell-framework module
    [Net.ServicePointManager]::SecurityProtocol = 'tls12, tls11';
    $ProgressPreference                         = 'SilentlyContinue';
    [string]$ScriptFile                         = 'C:\Users\Public\IcingaForWindows.ps1';

    Invoke-WebRequest `
        -UseBasicParsing `
        -Uri 'https://here/monitoring/icingaforwindows/IcingaForWindows.ps1' `
        -OutFile $ScriptFile;

    & $ScriptFile `
        -ModuleDirectory 'C:\Program Files\WindowsPowerShell\Modules\' `
        -InstallCommand '{"IfW-StableRepository":{"Values":["https://here/monitoring/icingaforwindows/stable"]}}' `
        -IcingaRepository 'https://here/monitoring/icingaforwindows/stable/ifw.repo.json' `
        -FrameworkVersion $frameworkversion `
        -SkipWizard;

The output of the IMC and commands as shown above remain the same.

Only after running Add-IcingaRepository -Name 'Icinga Stable' -RemotePath 'https://here/monitoring/icingaforwindows/stable/ifw.repo.json' -Force; the repo is set and visible in the IMC and the command Get-IcingaRepositories

Strangely the Update-Icinga and Install-IcingaComponent commands still don't care what repo I have set:

Install-IcingaComponent -name plugins -version "1.10.0"
Do you want to install component "plugins" from source "Icinga Stable" (https://packages.icinga.com/IcingaForWindows/stable/plugins/icinga-powershell-plugins-1.10.0.zip)? (Y/n):

Update-Icinga -name framework -version "1.10.1"
Do you want to install component "framework" from source "Icinga Stable" (https://packages.icinga.com/IcingaForWindows/stable/framework/icinga-powershell-framework-1.10.1.zip)? (Y/n): n
PS C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework> Get-IcingaRepositories

MemberType      : NoteProperty
IsSettable      : True
IsGettable      : True
Value           : @{LocalPath=;
                  RemotePath=https://here/monitoring/icingaforwindows/stable/ifw.repo.json;
                  CloneSource=; UseSCP=False; Order=0; Enabled=True}
TypeNameOfValue : System.Management.Automation.PSCustomObject
Name            : Icinga Stable
IsInstance      : True

I'm lost.

K0nne commented 1 year ago

I have the same problem.

log1-c commented 1 year ago

I just figured out that the "packages.icinga.com..." is hardcoded in the ifw.repo.json...

As I simply download the whole IcingaForWindows contents onto our internal repository/webserver, I get the hardcoded URL as well. I will now do an additional sed -i 's:packages.icinga.com\/IcingaForWindows:here\/monitoring\/icingaforwindows:' ifw.repo.json after syncing/downloading.

After that the Install-IcingaComponent command pulls from the correct path.

So the only problem that remains is the "original" one: The repository is not correctly set after the installation

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

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