Handle deprecated argument --key for Icinga Agent save-cert cmd

Fixes #62
This commit is contained in:
Lord Hepipud 2020-04-28 13:48:15 +02:00
parent 2fca1d3e2f
commit 429db105a8

View file

@ -48,11 +48,19 @@ function Install-IcingaAgentCertificates()
Write-Host ([string]::Format('Fetching trusted master certificate from "{0}"', $Endpoint)); Write-Host ([string]::Format('Fetching trusted master certificate from "{0}"', $Endpoint));
$arguments = [string]::Format('pki save-cert --key {0}{1}.key --trustedcert {0}trusted-parent.crt --host {2}', # Argument --key for save-cert is deprecated starting with Icinga 2.12.0
$CertificateDirectory, if (Compare-IcingaVersions -RequiredVersion '2.12.0') {
$Hostname, $arguments = [string]::Format('pki save-cert --trustedcert {0}trusted-parent.crt --host {1}',
$Endpoint $CertificateDirectory,
); $Endpoint
);
} else {
$arguments = [string]::Format('pki save-cert --key {0}{1}.key --trustedcert {0}trusted-parent.crt --host {2}',
$CertificateDirectory,
$Hostname,
$Endpoint
);
}
if ((Start-IcingaAgentCertificateProcess -Arguments $arguments) -eq $FALSE) { if ((Start-IcingaAgentCertificateProcess -Arguments $arguments) -eq $FALSE) {
Write-Host 'Unable to connect to your provided Icinga CA. Please verify the entered configuration is correct.' ` Write-Host 'Unable to connect to your provided Icinga CA. Please verify the entered configuration is correct.' `