Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

icinga -RebuildCache - add option to not start the IMC afterwards #573

Closed
stevie-sy opened this issue Aug 29, 2022 · 5 comments · Fixed by #650
Closed

icinga -RebuildCache - add option to not start the IMC afterwards #573

stevie-sy opened this issue Aug 29, 2022 · 5 comments · Fixed by #650
Assignees
Labels
Enhancement New feature or request Question Further information is requested
Milestone

Comments

@stevie-sy
Copy link

For rebuilding the Code Cache there exists the param -RebuildCache. Afterwards the IMC is started. But for automation - like sending this Cmdlet to every/some/many server(s) via WinRM this is not so fine.
For this action it would be very helpful if there is an additional option to don't start the IMC or to have an another cmdlet for such tasks.

I saw there exists the cmdlet Write-IcingaFrameworkCodeCache but it looks like it doesn't the same. e.g. if you install the PowerShell-moduls manully, icinga -RebuildCache is also doing some migration tasks if necessary

@LordHepipud
Copy link
Collaborator

Thank you for the issue. Basically you want to do the following two steps:

Invoke-IcingaForWindowsMigration;
Write-IcingaFrameworkCodeCache;

This will however not update the current PowerShell instance, as the module is already loaded. Therefor the full handling would be:

# Reset all cache files, including installed plugins
Copy-IcingaFrameworkCacheTemplate
# Update Framework Cache
Write-IcingaFrameworkCodeCache;
# Remove the global variable Icinga, to reset possible invalid states
Remove-Variable -Name 'Icinga' -Scope 'Global' -ErrorAction 'SilentlyContinue'
# Re-Import the entire Framework to apply changes
Import-Module 'icinga-powershell-framework' -Force;
Import-Module 'icinga-powershell-framework' -Global -Force;
# Apply migrations
Invoke-IcingaForWindowsMigration;

and after that your entire code.

We could implement yet another flag doing all these things for the user. but would I'm not sure about a suitable name and the benefit for the moment. Suggestions?

@LordHepipud LordHepipud added this to the v1.11.0 milestone Aug 29, 2022
@LordHepipud LordHepipud self-assigned this Aug 29, 2022
@LordHepipud LordHepipud added Enhancement New feature or request Question Further information is requested labels Aug 29, 2022
@stevie-sy
Copy link
Author

Good question. For the moment I have also no idea for a suitable name, because RebuildCache is already meaningful.

If youre create a param like -notStartIMC / -startIMC you'll need also a logic handling. Because icinga alone should start the IMC. Only in combination it should possible.
Or a new param like RebuildCacheWithoutIMC?

Or you put this code snippset into the docs if somebody like us is needs it also? Because we need this only for two cases:

  • error handling, if something went wrong on some or many servers
  • inital deployment of the framework with our internal tools. After we will use the repo management from Icinga for Windows after some interal tests and adjustments

@LordHepipud
Copy link
Collaborator

Well, what I mostly do at the moment is something like this

icinga -RebuildCache { Write-IcingaConsoleNotice 'Loading Icinga Shell' };

Because you can call ScriptBlocks which just checks if something was set and is executed. A simple Write-Host would be enough.

@stevie-sy
Copy link
Author

Thanks, works also fine. Maybe then is a small chapter (e.g. for automation with own tools) in the docs enough?!?

@tbauriedel
Copy link
Member

ref/NC/761567

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request Question Further information is requested
Projects
None yet
3 participants