[Fleet] Fix logstash output preconfiguration and fleet server instructions (#137474) (#137509)

(cherry picked from commit 9a76a55ff3)

Co-authored-by: Nicolas Chaulet <n.chaulet@gmail.com>
This commit is contained in:
Kibana Machine 2022-07-28 14:21:59 -04:00 committed by GitHub
parent 9fc5de139e
commit ebf8976c4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 4 deletions

View file

@ -62,16 +62,18 @@ const InstallFleetServerStepContent: React.FunctionComponent<{
const kibanaVersion = useKibanaVersion();
const { output } = useDefaultOutput();
const commandOutput = output?.type === 'elasticsearch' ? output : undefined;
const installCommands = (['linux', 'mac', 'windows', 'deb', 'rpm'] as PLATFORM_TYPE[]).reduce(
(acc, platform) => {
acc[platform] = getInstallCommandForPlatform(
platform,
output?.hosts?.[0] ?? '',
commandOutput?.hosts?.[0] ?? '<ELASTICSEARCH_HOST>',
serviceToken ?? '',
fleetServerPolicyId,
fleetServerHost,
deploymentMode === 'production',
output?.ca_trusted_fingerprint,
commandOutput?.ca_trusted_fingerprint,
kibanaVersion
);

View file

@ -112,6 +112,26 @@ describe('output preconfiguration', () => {
expect(spyAgentPolicyServicBumpAllAgentPoliciesForOutput).not.toBeCalled();
});
it('should create preconfigured logstash output that does not exist', async () => {
const soClient = savedObjectsClientMock.create();
const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;
await createOrUpdatePreconfiguredOutputs(soClient, esClient, [
{
id: 'non-existing-output-1',
name: 'Output 1',
type: 'logstash',
is_default: false,
is_default_monitoring: false,
hosts: ['test.fr'],
ssl: { certificate: 'test', key: 'test' },
},
]);
expect(mockedOutputService.create).toBeCalled();
expect(mockedOutputService.update).not.toBeCalled();
expect(spyAgentPolicyServicBumpAllAgentPoliciesForOutput).not.toBeCalled();
});
it('should set default hosts if hosts is not set output that does not exists', async () => {
const soClient = savedObjectsClientMock.create();
const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;

View file

@ -159,8 +159,12 @@ function isPreconfiguredOutputDifferentFromCurrent(
existingOutput.type !== preconfiguredOutput.type ||
(preconfiguredOutput.hosts &&
!isEqual(
existingOutput.hosts?.map(normalizeHostsForAgents),
preconfiguredOutput.hosts.map(normalizeHostsForAgents)
existingOutput?.type === 'elasticsearch'
? existingOutput.hosts?.map(normalizeHostsForAgents)
: existingOutput.hosts,
preconfiguredOutput.type === 'elasticsearch'
? preconfiguredOutput.hosts.map(normalizeHostsForAgents)
: preconfiguredOutput.hosts
)) ||
(preconfiguredOutput.ssl && !isEqual(preconfiguredOutput.ssl, existingOutput.ssl)) ||
existingOutput.ca_sha256 !== preconfiguredOutput.ca_sha256 ||