-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Hi,
I came across a bug while trying to deploy the Icinga2 Agent using the framework.
For reference, I'm integrating things with saltstack and tickets are generated in advance for each agent to be installed and connected to the master. The ca.crt is fetched directly by the agent during the signing process and not shared or copied beforehand.
I was using the now deprecated icinga-powershell-module for some time and everything worked fine.
Expected Behavior
The framework generates and sign the agent certificate using the ca.crt fetched from the master.
Default features are enabled after a successful install.
Current Behavior
After correctly generating and signing the certificate while installing the agent, the framework disables the API feature because it thinks that the ca.crt file is missing or not provided.
Possible Solution
I think the check after the certificate install process is wrong or not specific enough:
icinga-powershell-framework/lib/core/icingaagent/misc/Start-IcingaAgentInstallWizard.psm1
Line 564 in ac02ec7
if ($EmptyCA -eq $TRUE -Or $CertsInstalled -eq $FALSE) { |
$EmptyCA is indeed True when I execute Start-IcingaAgentInstallWizard because at the beginning I don't have the CA file available. However, during the icinga2 pki request process, the CA file is fetched and correctly written in the certificate directory.
Steps to Reproduce (for bugs)
Here is the command executed for the installation
PS C:\Users\Administrator> Start-IcingaAgentInstallWizard `
-UseDirectorSelfService 0 `
-PackageSource 'https://packages.icinga.com/windows/' `
-AllowVersionChanges 1 `
-AgentVersion 'release' `
-Endpoints master.example.com `
-CAPort 5665 `
-AcceptConnections 1`
-CAFile ''`
-EmptyCA 1`
-AcceptConnections 1 `
-AddFirewallRule 0 `
-ConvertEndpointIPConfig 0 `
-ParentZone master `
-AddDirectorGlobal 1 `
-AddGlobalTemplates 1 `
-GlobalZones @() `
-CAEndpoint 1.2.3.4 `
-EmptyTicket 0 `
-Ticket 'thisisaticket123456789' `
-ServiceUser LocalSystem `
-InstallFrameworkPlugins 1 `
-PluginsUrl 'https://github.com/Icinga/icinga-powershell-plugins/archive/v1.1.0/v1.1.0.zip' `
-InstallFrameworkService 1 `
-FrameworkServiceUrl 'https://github.com/Icinga/icinga-powershell-service/releases/download/v1.1.0/icinga-service-v1.1.0.zip' `
-ServiceDirectory 'C:\Program Files\icinga-framework-service\' `
-ServiceBin 'C:\Program Files\icinga-framework-service\icinga-service.exe' `
-RunInstaller
And here are the relevant log lines from the installation process:
[Warning]: Your ca.crt is not present. Manuall copy or fetching from your Icinga CA is required.
[Notice]: information/cli: Writing CA certificate to file 'C:\ProgramData\icinga2\var\lib\icinga2\certs\ca.crt'.
information/cli: Writing signed certificate to file 'C:\ProgramData\icinga2\var\lib\icinga2\certs\client.example.com.crt'.
[Notice]: Icinga certificates successfully installed
[Notice]: Api configuration has been written successfully
[Notice]: Feature "api" was successfully disabled
[Warning]: Your Icinga Agent API feature has been disabled. Please provide either your ca.crt or connect to a parent node for certificate requests. You can run "Install-IcingaAgentCertificates" 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"
If I manually enable the API and declare the zone and endpoint on the master, both connect successfully:
[2020-08-26 17:32:40 +0200] warning/JsonRpcConnection: API client disconnected for identity 'client.example.com'
[2020-08-26 17:32:40 +0200] warning/ApiListener: Removing API client for endpoint 'client.example.com'. 0 API clients left.
[2020-08-26 17:32:43 +0200] information/ApiListener: Reconnecting to endpoint 'client.example.com' via host 'client.example.com' and port '5665'
[2020-08-26 17:32:43 +0200] information/ApiListener: New client connection for identity 'client.example.com' to [4.3.2.1]:5665
[2020-08-26 17:32:43 +0200] information/ApiListener: Sending config updates for endpoint 'client.example.com' in zone 'client.example.com'.
[2020-08-26 17:32:43 +0200] information/ApiListener: Syncing configuration files for global zone 'global-templates' to endpoint 'client.example.com'.
[2020-08-26 17:32:43 +0200] information/ApiListener: Finished sending config file updates for endpoint 'client.example.com' in zone 'client.example.com'.
[2020-08-26 17:32:43 +0200] information/ApiListener: Syncing runtime objects to endpoint 'client.example.com'.
[2020-08-26 17:32:43 +0200] information/ApiListener: Finished syncing runtime objects to endpoint 'client.example.com'.
[2020-08-26 17:32:43 +0200] information/ApiListener: Finished sending runtime config updates for endpoint 'client.example.com' in zone 'client.example.com'.
[2020-08-26 17:32:43 +0200] information/ApiListener: Sending replay log for endpoint 'client.example.com' in zone 'client.example.com'.
[2020-08-26 17:32:43 +0200] information/ApiListener: Finished sending replay log for endpoint 'client.example.com' in zone 'client.example.com'.
[2020-08-26 17:32:43 +0200] information/ApiListener: Finished syncing endpoint 'client.example.com' in zone 'client.example.com'.
[2020-08-26 17:32:43 +0200] information/ApiListener: Finished reconnecting to endpoint 'client.example.com' via host 'client.example.com' and port '5665'
[2020-08-26 17:32:43 +0200] information/JsonRpcConnection: Received certificate request for CN 'client.example.com' signed by our CA.
[2020-08-26 17:32:43 +0200] information/JsonRpcConnection: The certificate for CN 'client.example.com' is valid and uptodate. Skipping automated renewal.
Context
A simple installation process of the icinga2 agent. Both the agent and the master are on the same network. CA is available through the master API and the generated ticket is provided at install time.
Your Environment
-
PowerShell Version used (
$PSVersionTable.PSVersion
): 5.1.14393.2273 -
Operating System and version (
Get-IcingaWindowsInformation Win32_OperatingSystem | Select-Object Version, BuildNumber, Caption
):
Caption : Microsoft Windows Server 2016 Standard
OSArchitecture : 64-bit
Version : 10.0.14393
BuildNumber : 14393