Fixes Icinga env corruption on Agent failure

This commit is contained in:
Lord Hepipud 2021-09-09 18:23:37 +02:00
parent 7b6b9e8224
commit 8492a39009
2 changed files with 27 additions and 19 deletions

View file

@ -16,6 +16,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#361](https://github.com/Icinga/icinga-powershell-framework/issues/361) Fixes IMC freeze on Icinga Director Self-Service installation, in case no Agent installation set on Self-Service API config * [#361](https://github.com/Icinga/icinga-powershell-framework/issues/361) Fixes IMC freeze on Icinga Director Self-Service installation, in case no Agent installation set on Self-Service API config
* [#362](https://github.com/Icinga/icinga-powershell-framework/issues/362) Fixes repository component installation from file share locations * [#362](https://github.com/Icinga/icinga-powershell-framework/issues/362) Fixes repository component installation from file share locations
* [#363](https://github.com/Icinga/icinga-powershell-framework/issues/363) Fixes unneeded continue for JEA process lookup, in case no JEA pid is present * [#363](https://github.com/Icinga/icinga-powershell-framework/issues/363) Fixes unneeded continue for JEA process lookup, in case no JEA pid is present
* [#365](https://github.com/Icinga/icinga-powershell-framework/issues/365) Fixes Icinga environment corruption on Icinga Agent installation failure
### Enhancements ### Enhancements

View file

@ -165,28 +165,35 @@ function Start-IcingaForWindowsInstallation()
if ($InstallAgent) { if ($InstallAgent) {
Set-IcingaPowerShellConfig -Path 'Framework.Icinga.AgentLocation' -Value $AgentInstallDir; Set-IcingaPowerShellConfig -Path 'Framework.Icinga.AgentLocation' -Value $AgentInstallDir;
Install-IcingaComponent -Name 'agent' -Version $AgentVersion -Confirm -Release; Install-IcingaComponent -Name 'agent' -Version $AgentVersion -Confirm -Release;
Reset-IcingaAgentConfigFile;
Move-IcingaAgentDefaultConfig; # Only continue this, if our installation was successful
Set-IcingaAgentNodeName -Hostname $Hostname; if ((Get-IcingaAgentInstallation).Installed) {
Set-IcingaAgentServiceUser -User $ServiceUser -Password (ConvertTo-IcingaSecureString $ServicePassword) -SetPermission | Out-Null; Reset-IcingaAgentConfigFile;
Install-IcingaAgentBaseFeatures; Move-IcingaAgentDefaultConfig;
Write-IcingaAgentApiConfig -Port $IcingaPort; Set-IcingaAgentNodeName -Hostname $Hostname;
Set-IcingaAgentServiceUser -User $ServiceUser -Password (ConvertTo-IcingaSecureString $ServicePassword) -SetPermission | Out-Null;
Install-IcingaAgentBaseFeatures;
Write-IcingaAgentApiConfig -Port $IcingaPort;
}
} }
if ((Install-IcingaAgentCertificates -Hostname $Hostname -Endpoint $IcingaCAServer -Port $IcingaPort -CACert $CertificateCAFile -Ticket $CertificateTicket) -eq $FALSE) { # Only continue this, if our installation was successful
Disable-IcingaAgentFeature 'api'; if ((Get-IcingaAgentInstallation).Installed) {
Write-IcingaConsoleWarning ` if ((Install-IcingaAgentCertificates -Hostname $Hostname -Endpoint $IcingaCAServer -Port $IcingaPort -CACert $CertificateCAFile -Ticket $CertificateTicket) -eq $FALSE) {
-Message '{0}{1}{2}{3}{4}' ` Disable-IcingaAgentFeature 'api';
-Objects ( Write-IcingaConsoleWarning `
'Your Icinga Agent API feature has been disabled. Please provide either your ca.crt ', -Message '{0}{1}{2}{3}{4}' `
'or connect to a parent node for certificate requests. You can run "Install-IcingaAgentCertificates" ', -Objects (
'with your configuration to properly create the host certificate and a valid certificate request. ', 'Your Icinga Agent API feature has been disabled. Please provide either your ca.crt ',
'After this you can enable the API feature by using "Enable-IcingaAgentFeature api" and restart the ', 'or connect to a parent node for certificate requests. You can run "Install-IcingaAgentCertificates" ',
'Icinga Agent service "Restart-IcingaService icinga2"' 'with your configuration to properly create the host certificate and a valid certificate request. ',
); 'After this you can enable the API feature by using "Enable-IcingaAgentFeature api" and restart the ',
} 'Icinga Agent service "Restart-IcingaService icinga2"'
);
}
Write-IcingaAgentZonesConfig -Endpoints $IcingaEndpoints -EndpointConnections $IcingaParentAddresses -ParentZone $IcingaZone -GlobalZones $GlobalZones -Hostname $Hostname; Write-IcingaAgentZonesConfig -Endpoints $IcingaEndpoints -EndpointConnections $IcingaParentAddresses -ParentZone $IcingaZone -GlobalZones $GlobalZones -Hostname $Hostname;
}
if ($InstallService) { if ($InstallService) {
Set-IcingaPowerShellConfig -Path 'Framework.Icinga.IcingaForWindowsService' -Value $WindowsServiceDir; Set-IcingaPowerShellConfig -Path 'Framework.Icinga.IcingaForWindowsService' -Value $WindowsServiceDir;