[Fleet] Update deb and rpm install commands (#218068)

Fixes https://github.com/elastic/kibana/issues/212609

## Summary

The `--install-servers` flag present in the enroll commands for fleet
servers and elastic agents doesn't work in case of `deb` and `rpm`
installers. It should be used `ELASTIC_AGENT_FLAVOR` instead (see [this
comment](https://github.com/elastic/kibana/issues/212609#issuecomment-2752335880)
explaining it).

I fixed the command in those cases and also added some unit tests (that
weren't present in some cases).

### Testing 
- try to enroll a fleet server or elastic agent
- check that `rpm` and `deb` commands don't have `--install-servers` in
the enroll commands but

```
sudo ELASTIC_AGENT_FLAVOR=servers dpkg -i $path_to_deb
```

### screenshots
<img width="780" alt="Screenshot 2025-04-14 at 16 40 39" src="http
<img width="743" alt="Screenshot 2025-04-14 at 16 40 30"
src="https://github.com/user-attachments/assets/0bb405a7-7682-44ed-959e-b81832fd84af"
/>

s://github.com/user-attachments/assets/f693f830-7e7f-43bd-a0ac-f378352cda93"
/>


### Checklist

- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
This commit is contained in:
Cristina Amico 2025-04-15 12:14:40 +02:00 committed by GitHub
parent 32d77a32d0
commit 7ffe810fc4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 620 additions and 118 deletions

View file

@ -140,14 +140,13 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-aarch64.rpm
sudo rpm -vi elastic-agent-9.0.0-aarch64.rpm
sudo ELASTIC_AGENT_FLAVOR=servers rpm -vi elastic-agent-9.0.0-aarch64.rpm
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll \\\\
--fleet-server-es=http://elasticsearch:9200 \\\\
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-port=8220 \\\\
--install-servers"
--fleet-server-port=8220"
`);
expect(
@ -159,14 +158,13 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-x86_64.rpm
sudo rpm -vi elastic-agent-9.0.0-x86_64.rpm
sudo ELASTIC_AGENT_FLAVOR=servers rpm -vi elastic-agent-9.0.0-x86_64.rpm
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll \\\\
--fleet-server-es=http://elasticsearch:9200 \\\\
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-port=8220 \\\\
--install-servers"
--fleet-server-port=8220"
`);
});
@ -180,14 +178,13 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-arm64.deb
sudo dpkg -i elastic-agent-9.0.0-arm64.deb
sudo ELASTIC_AGENT_FLAVOR=servers dpkg -i elastic-agent-9.0.0-arm64.deb
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll \\\\
--fleet-server-es=http://elasticsearch:9200 \\\\
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-port=8220 \\\\
--install-servers"
--fleet-server-port=8220"
`);
expect(
@ -199,14 +196,13 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-amd64.deb
sudo dpkg -i elastic-agent-9.0.0-amd64.deb
sudo ELASTIC_AGENT_FLAVOR=servers dpkg -i elastic-agent-9.0.0-amd64.deb
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll \\\\
--fleet-server-es=http://elasticsearch:9200 \\\\
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-port=8220 \\\\
--install-servers"
--fleet-server-port=8220"
`);
});
@ -370,15 +366,14 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-aarch64.rpm
sudo rpm -vi elastic-agent-9.0.0-aarch64.rpm
sudo ELASTIC_AGENT_FLAVOR=servers rpm -vi elastic-agent-9.0.0-aarch64.rpm
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll \\\\
--fleet-server-es=http://elasticsearch:9200 \\\\
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-policy=policy-1 \\\\
--fleet-server-port=8220 \\\\
--install-servers"
--fleet-server-port=8220"
`);
expect(
@ -391,15 +386,14 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-x86_64.rpm
sudo rpm -vi elastic-agent-9.0.0-x86_64.rpm
sudo ELASTIC_AGENT_FLAVOR=servers rpm -vi elastic-agent-9.0.0-x86_64.rpm
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll \\\\
--fleet-server-es=http://elasticsearch:9200 \\\\
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-policy=policy-1 \\\\
--fleet-server-port=8220 \\\\
--install-servers"
--fleet-server-port=8220"
`);
});
@ -414,15 +408,14 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-arm64.deb
sudo dpkg -i elastic-agent-9.0.0-arm64.deb
sudo ELASTIC_AGENT_FLAVOR=servers dpkg -i elastic-agent-9.0.0-arm64.deb
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll \\\\
--fleet-server-es=http://elasticsearch:9200 \\\\
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-policy=policy-1 \\\\
--fleet-server-port=8220 \\\\
--install-servers"
--fleet-server-port=8220"
`);
expect(
@ -435,15 +428,14 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-amd64.deb
sudo dpkg -i elastic-agent-9.0.0-amd64.deb
sudo ELASTIC_AGENT_FLAVOR=servers dpkg -i elastic-agent-9.0.0-amd64.deb
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll \\\\
--fleet-server-es=http://elasticsearch:9200 \\\\
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-policy=policy-1 \\\\
--fleet-server-port=8220 \\\\
--install-servers"
--fleet-server-port=8220"
`);
});
});
@ -652,7 +644,7 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-aarch64.rpm
sudo rpm -vi elastic-agent-9.0.0-aarch64.rpm
sudo ELASTIC_AGENT_FLAVOR=servers rpm -vi elastic-agent-9.0.0-aarch64.rpm
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll --url=http://fleetserver:8220 \\\\
@ -663,8 +655,7 @@ describe('getInstallCommandForPlatform', () => {
--fleet-server-es-ca=<PATH_TO_ES_CERT> \\\\
--fleet-server-cert=<PATH_TO_FLEET_SERVER_CERT> \\\\
--fleet-server-cert-key=<PATH_TO_FLEET_SERVER_CERT_KEY> \\\\
--fleet-server-port=8220 \\\\
--install-servers"
--fleet-server-port=8220"
`);
expect(
@ -679,7 +670,7 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-x86_64.rpm
sudo rpm -vi elastic-agent-9.0.0-x86_64.rpm
sudo ELASTIC_AGENT_FLAVOR=servers rpm -vi elastic-agent-9.0.0-x86_64.rpm
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll --url=http://fleetserver:8220 \\\\
@ -690,8 +681,7 @@ describe('getInstallCommandForPlatform', () => {
--fleet-server-es-ca=<PATH_TO_ES_CERT> \\\\
--fleet-server-cert=<PATH_TO_FLEET_SERVER_CERT> \\\\
--fleet-server-cert-key=<PATH_TO_FLEET_SERVER_CERT_KEY> \\\\
--fleet-server-port=8220 \\\\
--install-servers"
--fleet-server-port=8220"
`);
});
@ -708,7 +698,7 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-arm64.deb
sudo dpkg -i elastic-agent-9.0.0-arm64.deb
sudo ELASTIC_AGENT_FLAVOR=servers dpkg -i elastic-agent-9.0.0-arm64.deb
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll --url=http://fleetserver:8220 \\\\
@ -719,8 +709,7 @@ describe('getInstallCommandForPlatform', () => {
--fleet-server-es-ca=<PATH_TO_ES_CERT> \\\\
--fleet-server-cert=<PATH_TO_FLEET_SERVER_CERT> \\\\
--fleet-server-cert-key=<PATH_TO_FLEET_SERVER_CERT_KEY> \\\\
--fleet-server-port=8220 \\\\
--install-servers"
--fleet-server-port=8220"
`);
expect(
@ -735,7 +724,7 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-amd64.deb
sudo dpkg -i elastic-agent-9.0.0-amd64.deb
sudo ELASTIC_AGENT_FLAVOR=servers dpkg -i elastic-agent-9.0.0-amd64.deb
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll --url=http://fleetserver:8220 \\\\
@ -746,8 +735,7 @@ describe('getInstallCommandForPlatform', () => {
--fleet-server-es-ca=<PATH_TO_ES_CERT> \\\\
--fleet-server-cert=<PATH_TO_FLEET_SERVER_CERT> \\\\
--fleet-server-cert-key=<PATH_TO_FLEET_SERVER_CERT_KEY> \\\\
--fleet-server-port=8220 \\\\
--install-servers"
--fleet-server-port=8220"
`);
});
@ -771,21 +759,20 @@ describe('getInstallCommandForPlatform', () => {
});
expect(res).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--amd64.deb
sudo dpkg -i elastic-agent--amd64.deb
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll --url=http://fleetserver:8220 \\\\
--fleet-server-es=http://elasticsearch:9200 \\\\
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-policy=policy-1 \\\\
--certificate-authorities='cert authorities' \\\\
--fleet-server-es-ca='path/to/EScert' \\\\
--fleet-server-cert='path/to/cert' \\\\
--fleet-server-cert-key=<PATH_TO_FLEET_SERVER_CERT_KEY> \\\\
--fleet-server-port=8220 \\\\
--install-servers"
`);
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--amd64.deb
sudo ELASTIC_AGENT_FLAVOR=servers dpkg -i elastic-agent--amd64.deb
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll --url=http://fleetserver:8220 \\\\
--fleet-server-es=http://elasticsearch:9200 \\\\
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-policy=policy-1 \\\\
--certificate-authorities='cert authorities' \\\\
--fleet-server-es-ca='path/to/EScert' \\\\
--fleet-server-cert='path/to/cert' \\\\
--fleet-server-cert-key=<PATH_TO_FLEET_SERVER_CERT_KEY> \\\\
--fleet-server-port=8220"
`);
});
it('should return the command with SSL options and placeholders', () => {
const fullFleetServerHost = {
@ -805,21 +792,20 @@ describe('getInstallCommandForPlatform', () => {
});
expect(res).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--amd64.deb
sudo dpkg -i elastic-agent--amd64.deb
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll --url=http://fleetserver:8220 \\\\
--fleet-server-es=http://elasticsearch:9200 \\\\
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-policy=policy-1 \\\\
--certificate-authorities='cert authorities' \\\\
--fleet-server-es-ca=<PATH_TO_ES_CERT> \\\\
--fleet-server-cert='path/to/cert' \\\\
--fleet-server-cert-key=<PATH_TO_FLEET_SERVER_CERT_KEY> \\\\
--fleet-server-port=8220 \\\\
--install-servers"
`);
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--amd64.deb
sudo ELASTIC_AGENT_FLAVOR=servers dpkg -i elastic-agent--amd64.deb
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll --url=http://fleetserver:8220 \\\\
--fleet-server-es=http://elasticsearch:9200 \\\\
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-policy=policy-1 \\\\
--certificate-authorities='cert authorities' \\\\
--fleet-server-es-ca=<PATH_TO_ES_CERT> \\\\
--fleet-server-cert='path/to/cert' \\\\
--fleet-server-cert-key=<PATH_TO_FLEET_SERVER_CERT_KEY> \\\\
--fleet-server-port=8220"
`);
});
});
});
@ -1107,7 +1093,7 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-aarch64.rpm --proxy http://download-src-proxy:2222
sudo rpm -vi elastic-agent-9.0.0-aarch64.rpm
sudo ELASTIC_AGENT_FLAVOR=servers rpm -vi elastic-agent-9.0.0-aarch64.rpm
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll \\\\
@ -1115,7 +1101,6 @@ describe('getInstallCommandForPlatform', () => {
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-policy=policy-1 \\\\
--fleet-server-port=8220 \\\\
--install-servers \\\\
--proxy-url=http://es-proxy:1111"
`);
@ -1149,7 +1134,7 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-x86_64.rpm --proxy http://download-src-proxy:2222
sudo rpm -vi elastic-agent-9.0.0-x86_64.rpm
sudo ELASTIC_AGENT_FLAVOR=servers rpm -vi elastic-agent-9.0.0-x86_64.rpm
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll \\\\
@ -1157,7 +1142,6 @@ describe('getInstallCommandForPlatform', () => {
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-policy=policy-1 \\\\
--fleet-server-port=8220 \\\\
--install-servers \\\\
--proxy-url=http://es-proxy:1111"
`);
});
@ -1193,7 +1177,7 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-arm64.deb --proxy http://download-src-proxy:2222
sudo dpkg -i elastic-agent-9.0.0-arm64.deb
sudo ELASTIC_AGENT_FLAVOR=servers dpkg -i elastic-agent-9.0.0-arm64.deb
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll \\\\
@ -1201,7 +1185,6 @@ describe('getInstallCommandForPlatform', () => {
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-policy=policy-1 \\\\
--fleet-server-port=8220 \\\\
--install-servers \\\\
--proxy-url=http://es-proxy:1111"
`);
@ -1235,7 +1218,7 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-amd64.deb --proxy http://download-src-proxy:2222
sudo dpkg -i elastic-agent-9.0.0-amd64.deb
sudo ELASTIC_AGENT_FLAVOR=servers dpkg -i elastic-agent-9.0.0-amd64.deb
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll \\\\
@ -1243,7 +1226,6 @@ describe('getInstallCommandForPlatform', () => {
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-policy=policy-1 \\\\
--fleet-server-port=8220 \\\\
--install-servers \\\\
--proxy-url=http://es-proxy:1111"
`);
});
@ -1552,7 +1534,7 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-aarch64.rpm --proxy http://download-src-proxy:2222 --proxy-header \\"Accept-Language=en-US,en;q=0.5\\" --proxy-header \\"second-header=second-value\\"
sudo rpm -vi elastic-agent-9.0.0-aarch64.rpm
sudo ELASTIC_AGENT_FLAVOR=servers rpm -vi elastic-agent-9.0.0-aarch64.rpm
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll \\\\
@ -1560,7 +1542,6 @@ describe('getInstallCommandForPlatform', () => {
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-policy=policy-1 \\\\
--fleet-server-port=8220 \\\\
--install-servers \\\\
--proxy-url=http://es-proxy:1111 \\\\
--proxy-header=\\"X-Forwarded-For=forwarded-value\\" \\\\
--proxy-header=\\"test-header=test-value\\""
@ -1574,7 +1555,7 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-x86_64.rpm --proxy http://download-src-proxy:2222 --proxy-header \\"Accept-Language=en-US,en;q=0.5\\" --proxy-header \\"second-header=second-value\\"
sudo rpm -vi elastic-agent-9.0.0-x86_64.rpm
sudo ELASTIC_AGENT_FLAVOR=servers rpm -vi elastic-agent-9.0.0-x86_64.rpm
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll \\\\
@ -1582,7 +1563,6 @@ describe('getInstallCommandForPlatform', () => {
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-policy=policy-1 \\\\
--fleet-server-port=8220 \\\\
--install-servers \\\\
--proxy-url=http://es-proxy:1111 \\\\
--proxy-header=\\"X-Forwarded-For=forwarded-value\\" \\\\
--proxy-header=\\"test-header=test-value\\""
@ -1632,7 +1612,7 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-arm64.deb --proxy http://download-src-proxy:2222 --proxy-header \\"Accept-Language=en-US,en;q=0.5\\" --proxy-header \\"second-header=second-value\\"
sudo dpkg -i elastic-agent-9.0.0-arm64.deb
sudo ELASTIC_AGENT_FLAVOR=servers dpkg -i elastic-agent-9.0.0-arm64.deb
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll \\\\
@ -1640,7 +1620,6 @@ describe('getInstallCommandForPlatform', () => {
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-policy=policy-1 \\\\
--fleet-server-port=8220 \\\\
--install-servers \\\\
--proxy-url=http://es-proxy:1111 \\\\
--proxy-header=\\"X-Forwarded-For=forwarded-value\\" \\\\
--proxy-header=\\"test-header=test-value\\""
@ -1654,7 +1633,7 @@ describe('getInstallCommandForPlatform', () => {
})
).toMatchInlineSnapshot(`
"curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-amd64.deb --proxy http://download-src-proxy:2222 --proxy-header \\"Accept-Language=en-US,en;q=0.5\\" --proxy-header \\"second-header=second-value\\"
sudo dpkg -i elastic-agent-9.0.0-amd64.deb
sudo ELASTIC_AGENT_FLAVOR=servers dpkg -i elastic-agent-9.0.0-amd64.deb
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent
sudo elastic-agent enroll \\\\
@ -1662,7 +1641,6 @@ describe('getInstallCommandForPlatform', () => {
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-policy=policy-1 \\\\
--fleet-server-port=8220 \\\\
--install-servers \\\\
--proxy-url=http://es-proxy:1111 \\\\
--proxy-header=\\"X-Forwarded-For=forwarded-value\\" \\\\
--proxy-header=\\"test-header=test-value\\""

View file

@ -11,6 +11,7 @@ import {
getDownloadSourceProxyArgs,
} from '../../../../../components/enrollment_instructions/manual';
import type { PLATFORM_TYPE } from '../../../hooks';
import { PLATFORM_WITH_INSTALL_SERVERS } from '../../../hooks';
export type CommandsByPlatform = {
[key in PLATFORM_TYPE]: string;
@ -79,25 +80,25 @@ function getArtifact(
deb_aarch64: {
downloadCommand: [
`curl -L -O ${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-arm64.deb${appendCurlDownloadSourceProxyArgs}`,
`sudo dpkg -i elastic-agent-${kibanaVersion}-arm64.deb`,
`sudo ELASTIC_AGENT_FLAVOR=servers dpkg -i elastic-agent-${kibanaVersion}-arm64.deb`,
].join(`\n`),
},
deb_x86_64: {
downloadCommand: [
`curl -L -O ${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-amd64.deb${appendCurlDownloadSourceProxyArgs}`,
`sudo dpkg -i elastic-agent-${kibanaVersion}-amd64.deb`,
`sudo ELASTIC_AGENT_FLAVOR=servers dpkg -i elastic-agent-${kibanaVersion}-amd64.deb`,
].join(`\n`),
},
rpm_aarch64: {
downloadCommand: [
`curl -L -O ${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-aarch64.rpm${appendCurlDownloadSourceProxyArgs}`,
`sudo rpm -vi elastic-agent-${kibanaVersion}-aarch64.rpm`,
`sudo ELASTIC_AGENT_FLAVOR=servers rpm -vi elastic-agent-${kibanaVersion}-aarch64.rpm`,
].join(`\n`),
},
rpm_x86_64: {
downloadCommand: [
`curl -L -O ${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-x86_64.rpm${appendCurlDownloadSourceProxyArgs}`,
`sudo rpm -vi elastic-agent-${kibanaVersion}-x86_64.rpm`,
`sudo ELASTIC_AGENT_FLAVOR=servers rpm -vi elastic-agent-${kibanaVersion}-x86_64.rpm`,
].join(`\n`),
},
kubernetes: {
@ -175,7 +176,9 @@ export function getInstallCommandForPlatform({
commandArguments.push(['fleet-server-port', '8220']);
commandArguments.push(['install-servers']);
if (PLATFORM_WITH_INSTALL_SERVERS.includes(platform)) {
commandArguments.push(['install-servers']);
}
const enrollmentProxyArgs = [];
if (esOutputProxy) {

View file

@ -0,0 +1,467 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { ManualInstructions } from '.';
describe('ManualInstructions', () => {
describe('With basic parameters', () => {
const result = ManualInstructions({
apiKey: 'APIKEY',
fleetServerHost: 'https://testhost',
agentVersion: '9.0.0',
});
it('should return instructions for linux_aarch64', async () => {
expect(result.linux_aarch64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-linux-arm64.tar.gz ',
' tar xzvf elastic-agent-9.0.0-linux-arm64.tar.gz',
' cd elastic-agent-9.0.0-linux-arm64',
' sudo ./elastic-agent install --url=https://testhost --enrollment-token=APIKEY',
]);
});
it('should return instructions for linux_x86_64', async () => {
expect(result.linux_x86_64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-linux-x86_64.tar.gz ',
'tar xzvf elastic-agent-9.0.0-linux-x86_64.tar.gz',
'cd elastic-agent-9.0.0-linux-x86_64',
'sudo ./elastic-agent install --url=https://testhost --enrollment-token=APIKEY',
]);
});
it('should return instructions for deb_aarch64', async () => {
expect(result.deb_aarch64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-arm64.deb ',
'sudo dpkg -i elastic-agent-9.0.0-arm64.deb',
'sudo systemctl enable elastic-agent ',
'sudo systemctl start elastic-agent ',
'sudo elastic-agent enroll --url=https://testhost --enrollment-token=APIKEY ',
'',
]);
});
it('should return instructions for deb_x86_64', async () => {
expect(result.deb_x86_64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-amd64.deb ',
'sudo dpkg -i elastic-agent-9.0.0-amd64.deb',
'sudo systemctl enable elastic-agent ',
'sudo systemctl start elastic-agent ',
'sudo elastic-agent enroll --url=https://testhost --enrollment-token=APIKEY ',
'',
]);
});
it('should return instructions for rpm_aarch64', async () => {
expect(result.rpm_aarch64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-aarch64.rpm ',
'sudo rpm -vi elastic-agent-9.0.0-aarch64.rpm',
'sudo systemctl enable elastic-agent ',
'sudo systemctl start elastic-agent ',
'sudo elastic-agent enroll --url=https://testhost --enrollment-token=APIKEY ',
'',
]);
});
it('should return instructions for rpm_x86_64', async () => {
expect(result.rpm_x86_64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-x86_64.rpm ',
'sudo rpm -vi elastic-agent-9.0.0-x86_64.rpm',
'sudo systemctl enable elastic-agent ',
'sudo systemctl start elastic-agent ',
'sudo elastic-agent enroll --url=https://testhost --enrollment-token=APIKEY ',
'',
]);
});
it('should return instructions for mac_aarch64', async () => {
expect(result.mac_aarch64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-darwin-aarch64.tar.gz ',
'tar xzvf elastic-agent-9.0.0-darwin-aarch64.tar.gz',
'cd elastic-agent-9.0.0-darwin-aarch64',
'sudo ./elastic-agent install --url=https://testhost --enrollment-token=APIKEY',
]);
});
it('should return instructions for mac_x86_64', async () => {
expect(result.mac_x86_64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-darwin-x86_64.tar.gz ',
'tar xzvf elastic-agent-9.0.0-darwin-x86_64.tar.gz',
'cd elastic-agent-9.0.0-darwin-x86_64',
'sudo ./elastic-agent install --url=https://testhost --enrollment-token=APIKEY',
]);
});
it('should return instructions for kubernetes', async () => {
expect(result.kubernetes.split('\n')).toEqual([
'kubectl apply -f elastic-agent-managed-kubernetes.yml',
]);
});
});
describe('With showInstallServers', () => {
const result = ManualInstructions({
apiKey: 'APIKEY',
fleetServerHost: 'https://testhost',
agentVersion: '9.0.0',
showInstallServers: true,
});
it('should return instructions for linux_aarch64', async () => {
expect(result.linux_aarch64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-linux-arm64.tar.gz ',
' tar xzvf elastic-agent-9.0.0-linux-arm64.tar.gz',
' cd elastic-agent-9.0.0-linux-arm64',
' sudo ./elastic-agent install --url=https://testhost --enrollment-token=APIKEY --install-servers',
]);
});
it('should return instructions for linux_x86_64', async () => {
expect(result.linux_x86_64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-linux-x86_64.tar.gz ',
'tar xzvf elastic-agent-9.0.0-linux-x86_64.tar.gz',
'cd elastic-agent-9.0.0-linux-x86_64',
'sudo ./elastic-agent install --url=https://testhost --enrollment-token=APIKEY --install-servers',
]);
});
it('should return instructions for deb_aarch64', async () => {
expect(result.deb_aarch64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-arm64.deb ',
'sudo ELASTIC_AGENT_FLAVOR=servers dpkg -i elastic-agent-9.0.0-arm64.deb',
'sudo systemctl enable elastic-agent ',
'sudo systemctl start elastic-agent ',
'sudo elastic-agent enroll --url=https://testhost --enrollment-token=APIKEY ',
'',
]);
});
it('should return instructions for deb_x86_64', async () => {
expect(result.deb_x86_64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-amd64.deb ',
'sudo ELASTIC_AGENT_FLAVOR=servers dpkg -i elastic-agent-9.0.0-amd64.deb',
'sudo systemctl enable elastic-agent ',
'sudo systemctl start elastic-agent ',
'sudo elastic-agent enroll --url=https://testhost --enrollment-token=APIKEY ',
'',
]);
});
it('should return instructions for rpm_aarch64', async () => {
expect(result.rpm_aarch64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-aarch64.rpm ',
'sudo ELASTIC_AGENT_FLAVOR=servers rpm -vi elastic-agent-9.0.0-aarch64.rpm',
'sudo systemctl enable elastic-agent ',
'sudo systemctl start elastic-agent ',
'sudo elastic-agent enroll --url=https://testhost --enrollment-token=APIKEY ',
'',
]);
});
it('should return instructions for rpm_x86_64', async () => {
expect(result.rpm_x86_64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-x86_64.rpm ',
'sudo ELASTIC_AGENT_FLAVOR=servers rpm -vi elastic-agent-9.0.0-x86_64.rpm',
'sudo systemctl enable elastic-agent ',
'sudo systemctl start elastic-agent ',
'sudo elastic-agent enroll --url=https://testhost --enrollment-token=APIKEY ',
'',
]);
});
it('should return instructions for mac_aarch64', async () => {
expect(result.mac_aarch64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-darwin-aarch64.tar.gz ',
'tar xzvf elastic-agent-9.0.0-darwin-aarch64.tar.gz',
'cd elastic-agent-9.0.0-darwin-aarch64',
'sudo ./elastic-agent install --url=https://testhost --enrollment-token=APIKEY --install-servers',
]);
});
it('should return instructions for mac_x86_64', async () => {
expect(result.mac_x86_64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-darwin-x86_64.tar.gz ',
'tar xzvf elastic-agent-9.0.0-darwin-x86_64.tar.gz',
'cd elastic-agent-9.0.0-darwin-x86_64',
'sudo ./elastic-agent install --url=https://testhost --enrollment-token=APIKEY --install-servers',
]);
});
it('should return instructions for kubernetes', async () => {
expect(result.kubernetes.split('\n')).toEqual([
'kubectl apply -f elastic-agent-managed-kubernetes.yml',
]);
});
it('should return instructions for googleCloudShell', async () => {
expect(result.googleCloudShell.split('\n')).toEqual([
'gcloud config set project <PROJECT_ID> && FLEET_URL=https://testhost ENROLLMENT_TOKEN=APIKEY STACK_VERSION=9.0.0 ./deploy.sh',
]);
});
});
describe('With fleetProxy', () => {
const result = ManualInstructions({
apiKey: 'APIKEY',
fleetServerHost: 'https://testhost',
agentVersion: '9.0.0',
fleetProxy: {
id: 'id1',
name: 'test-proxy',
url: 'http://test-proxy',
is_preconfigured: false,
proxy_headers: { test1: 'header' },
},
});
it('should return instructions for linux_aarch64', async () => {
expect(result.linux_aarch64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-linux-arm64.tar.gz ',
' tar xzvf elastic-agent-9.0.0-linux-arm64.tar.gz',
' cd elastic-agent-9.0.0-linux-arm64',
' sudo ./elastic-agent install --url=https://testhost --enrollment-token=APIKEY --proxy-url=http://test-proxy --proxy-header "test1=header"',
]);
});
it('should return instructions for linux_x86_64', async () => {
expect(result.linux_x86_64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-linux-x86_64.tar.gz ',
'tar xzvf elastic-agent-9.0.0-linux-x86_64.tar.gz',
'cd elastic-agent-9.0.0-linux-x86_64',
'sudo ./elastic-agent install --url=https://testhost --enrollment-token=APIKEY --proxy-url=http://test-proxy --proxy-header "test1=header"',
]);
});
it('should return instructions for deb_aarch64', async () => {
expect(result.deb_aarch64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-arm64.deb ',
'sudo dpkg -i elastic-agent-9.0.0-arm64.deb',
'sudo systemctl enable elastic-agent ',
'sudo systemctl start elastic-agent ',
'sudo elastic-agent enroll --url=https://testhost --enrollment-token=APIKEY --proxy-url=http://test-proxy --proxy-header "test1=header" ',
'',
]);
});
it('should return instructions for deb_x86_64', async () => {
expect(result.deb_x86_64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-amd64.deb ',
'sudo dpkg -i elastic-agent-9.0.0-amd64.deb',
'sudo systemctl enable elastic-agent ',
'sudo systemctl start elastic-agent ',
'sudo elastic-agent enroll --url=https://testhost --enrollment-token=APIKEY --proxy-url=http://test-proxy --proxy-header "test1=header" ',
'',
]);
});
it('should return instructions for rpm_aarch64', async () => {
expect(result.rpm_aarch64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-aarch64.rpm ',
'sudo rpm -vi elastic-agent-9.0.0-aarch64.rpm',
'sudo systemctl enable elastic-agent ',
'sudo systemctl start elastic-agent ',
'sudo elastic-agent enroll --url=https://testhost --enrollment-token=APIKEY --proxy-url=http://test-proxy --proxy-header "test1=header" ',
'',
]);
});
it('should return instructions for rpm_x86_64', async () => {
expect(result.rpm_x86_64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-x86_64.rpm ',
'sudo rpm -vi elastic-agent-9.0.0-x86_64.rpm',
'sudo systemctl enable elastic-agent ',
'sudo systemctl start elastic-agent ',
'sudo elastic-agent enroll --url=https://testhost --enrollment-token=APIKEY --proxy-url=http://test-proxy --proxy-header "test1=header" ',
'',
]);
});
it('should return instructions for mac_aarch64', async () => {
expect(result.mac_aarch64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-darwin-aarch64.tar.gz ',
'tar xzvf elastic-agent-9.0.0-darwin-aarch64.tar.gz',
'cd elastic-agent-9.0.0-darwin-aarch64',
'sudo ./elastic-agent install --url=https://testhost --enrollment-token=APIKEY --proxy-url=http://test-proxy --proxy-header "test1=header"',
]);
});
it('should return instructions for mac_x86_64', async () => {
expect(result.mac_x86_64.split('\n')).toEqual([
'curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-darwin-x86_64.tar.gz ',
'tar xzvf elastic-agent-9.0.0-darwin-x86_64.tar.gz',
'cd elastic-agent-9.0.0-darwin-x86_64',
'sudo ./elastic-agent install --url=https://testhost --enrollment-token=APIKEY --proxy-url=http://test-proxy --proxy-header "test1=header"',
]);
});
it('should return instructions for kubernetes', async () => {
expect(result.kubernetes.split('\n')).toEqual([
'kubectl apply -f elastic-agent-managed-kubernetes.yml',
]);
});
it('should return instructions for googleCloudShell', async () => {
expect(result.googleCloudShell.split('\n')).toEqual([
'gcloud config set project <PROJECT_ID> && FLEET_URL=https://testhost ENROLLMENT_TOKEN=APIKEY --proxy-url=http://test-proxy --proxy-header "test1=header" STACK_VERSION=9.0.0 ./deploy.sh',
]);
});
});
describe('With downloadSource and downloadSourceProxy', () => {
const result = ManualInstructions({
apiKey: 'APIKEY',
fleetServerHost: 'https://testhost',
agentVersion: '9.0.0',
downloadSource: {
name: 'ds',
host: 'http://localregistry.co',
proxy_id: 'ds_id',
} as any,
downloadSourceProxy: {
id: 'ds_id',
name: 'ds-proxy',
url: 'http://ds-proxy',
} as any,
});
it('should return instructions for linux_aarch64', async () => {
expect(result.linux_aarch64.split('\n')).toEqual([
'curl -L -O http://localregistry.co/beats/elastic-agent/elastic-agent-9.0.0-linux-arm64.tar.gz --proxy http://ds-proxy',
' tar xzvf elastic-agent-9.0.0-linux-arm64.tar.gz',
' cd elastic-agent-9.0.0-linux-arm64',
' sudo ./elastic-agent install --url=https://testhost --enrollment-token=APIKEY',
]);
});
it('should return instructions for linux_x86_64', async () => {
expect(result.linux_x86_64.split('\n')).toEqual([
'curl -L -O http://localregistry.co/beats/elastic-agent/elastic-agent-9.0.0-linux-x86_64.tar.gz --proxy http://ds-proxy',
'tar xzvf elastic-agent-9.0.0-linux-x86_64.tar.gz',
'cd elastic-agent-9.0.0-linux-x86_64',
'sudo ./elastic-agent install --url=https://testhost --enrollment-token=APIKEY',
]);
});
it('should return instructions for deb_aarch64', async () => {
expect(result.deb_aarch64.split('\n')).toEqual([
'curl -L -O http://localregistry.co/beats/elastic-agent/elastic-agent-9.0.0-arm64.deb --proxy http://ds-proxy',
'sudo dpkg -i elastic-agent-9.0.0-arm64.deb',
'sudo systemctl enable elastic-agent ',
'sudo systemctl start elastic-agent ',
'sudo elastic-agent enroll --url=https://testhost --enrollment-token=APIKEY ',
'',
]);
});
it('should return instructions for deb_x86_64', async () => {
expect(result.deb_x86_64.split('\n')).toEqual([
'curl -L -O http://localregistry.co/beats/elastic-agent/elastic-agent-9.0.0-amd64.deb --proxy http://ds-proxy',
'sudo dpkg -i elastic-agent-9.0.0-amd64.deb',
'sudo systemctl enable elastic-agent ',
'sudo systemctl start elastic-agent ',
'sudo elastic-agent enroll --url=https://testhost --enrollment-token=APIKEY ',
'',
]);
});
it('should return instructions for rpm_aarch64', async () => {
expect(result.rpm_aarch64.split('\n')).toEqual([
'curl -L -O http://localregistry.co/beats/elastic-agent/elastic-agent-9.0.0-aarch64.rpm --proxy http://ds-proxy',
'sudo rpm -vi elastic-agent-9.0.0-aarch64.rpm',
'sudo systemctl enable elastic-agent ',
'sudo systemctl start elastic-agent ',
'sudo elastic-agent enroll --url=https://testhost --enrollment-token=APIKEY ',
'',
]);
});
it('should return instructions for rpm_x86_64', async () => {
expect(result.rpm_x86_64.split('\n')).toEqual([
'curl -L -O http://localregistry.co/beats/elastic-agent/elastic-agent-9.0.0-x86_64.rpm --proxy http://ds-proxy',
'sudo rpm -vi elastic-agent-9.0.0-x86_64.rpm',
'sudo systemctl enable elastic-agent ',
'sudo systemctl start elastic-agent ',
'sudo elastic-agent enroll --url=https://testhost --enrollment-token=APIKEY ',
'',
]);
});
it('should return instructions for mac_aarch64', async () => {
expect(result.mac_aarch64.split('\n')).toEqual([
'curl -L -O http://localregistry.co/beats/elastic-agent/elastic-agent-9.0.0-darwin-aarch64.tar.gz --proxy http://ds-proxy',
'tar xzvf elastic-agent-9.0.0-darwin-aarch64.tar.gz',
'cd elastic-agent-9.0.0-darwin-aarch64',
'sudo ./elastic-agent install --url=https://testhost --enrollment-token=APIKEY',
]);
});
it('should return instructions for mac_x86_64', async () => {
expect(result.mac_x86_64.split('\n')).toEqual([
'curl -L -O http://localregistry.co/beats/elastic-agent/elastic-agent-9.0.0-darwin-x86_64.tar.gz --proxy http://ds-proxy',
'tar xzvf elastic-agent-9.0.0-darwin-x86_64.tar.gz',
'cd elastic-agent-9.0.0-darwin-x86_64',
'sudo ./elastic-agent install --url=https://testhost --enrollment-token=APIKEY',
]);
});
it('should return instructions for kubernetes', async () => {
expect(result.kubernetes.split('\n')).toEqual([
'kubectl apply -f elastic-agent-managed-kubernetes.yml',
]);
});
});
describe('For googleCloudShell', () => {
it('should return instructions with basic commands', async () => {
const result = ManualInstructions({
apiKey: 'APIKEY',
fleetServerHost: 'https://testhost',
agentVersion: '9.0.0',
});
expect(result.googleCloudShell).toEqual(
'gcloud config set project <PROJECT_ID> && FLEET_URL=https://testhost ENROLLMENT_TOKEN=APIKEY STACK_VERSION=9.0.0 ./deploy.sh'
);
});
it('should return correct project_id', async () => {
const result = ManualInstructions({
apiKey: 'APIKEY',
fleetServerHost: 'https://testhost',
agentVersion: '9.0.0',
gcpProjectId: 'gcpID',
});
expect(result.googleCloudShell).toEqual(
'gcloud config set project gcpID && FLEET_URL=https://testhost ENROLLMENT_TOKEN=APIKEY STACK_VERSION=9.0.0 ./deploy.sh'
);
});
it('should return gcpProjectId when gcpAccountType = organization-account', async () => {
const result = ManualInstructions({
apiKey: 'APIKEY',
fleetServerHost: 'https://testhost',
agentVersion: '9.0.0',
gcpAccountType: 'organization-account',
gcpOrganizationId: 'test-org',
});
expect(result.googleCloudShell).toEqual(
'gcloud config set project <PROJECT_ID> && ORG_ID=test-org FLEET_URL=https://testhost ENROLLMENT_TOKEN=APIKEY STACK_VERSION=9.0.0 ./deploy.sh'
);
});
it('should not return gcpProjectId when gcpAccountType != organization-account', async () => {
const result = ManualInstructions({
apiKey: 'APIKEY',
fleetServerHost: 'https://testhost',
agentVersion: '9.0.0',
gcpAccountType: '',
gcpOrganizationId: 'test-org',
});
expect(result.googleCloudShell).toEqual(
'gcloud config set project <PROJECT_ID> && FLEET_URL=https://testhost ENROLLMENT_TOKEN=APIKEY STACK_VERSION=9.0.0 ./deploy.sh'
);
});
});
});

View file

@ -6,14 +6,22 @@
*/
import { DEFAULT_DOWNLOAD_SOURCE_URI } from '../../../../common/constants';
import { PLATFORM_WITH_INSTALL_SERVERS, type EXTENDED_PLATFORM_TYPE } from '../../../hooks';
import type { DownloadSource, FleetProxy } from '../../../types';
function getfleetServerHostsEnrollArgs(
apiKey: string,
fleetServerHost: string,
fleetProxy?: FleetProxy,
showInstallServers: boolean = false
) {
function getFleetServerHostsEnrollArgs({
apiKey,
fleetServerHost,
fleetProxy,
showInstallServers,
platform,
}: {
apiKey: string;
fleetServerHost: string;
fleetProxy?: FleetProxy;
showInstallServers?: boolean;
platform: EXTENDED_PLATFORM_TYPE;
}) {
const proxyHeadersArgs = fleetProxy?.proxy_headers
? Object.entries(fleetProxy.proxy_headers).reduce((acc, [proxyKey, proyVal]) => {
acc += ` --proxy-header "${proxyKey}=${proyVal}"`;
@ -22,7 +30,10 @@ function getfleetServerHostsEnrollArgs(
}, '')
: '';
const proxyArgs = fleetProxy ? ` --proxy-url=${fleetProxy.url}${proxyHeadersArgs}` : '';
const showInstallServersArgs = showInstallServers ? ' --install-servers' : '';
const showInstallServersArgs =
showInstallServers && PLATFORM_WITH_INSTALL_SERVERS.includes(platform)
? ' --install-servers'
: '';
return `--url=${
fleetServerHost || `FLEET_SERVER_HOST`
} --enrollment-token=${apiKey}${proxyArgs}${showInstallServersArgs}`;
@ -84,71 +95,90 @@ export const ManualInstructions = ({
gcpAccountType?: string;
showInstallServers?: boolean;
}) => {
const enrollArgs = getfleetServerHostsEnrollArgs(
apiKey,
fleetServerHost,
fleetProxy,
showInstallServers
);
const getEnrollArgsByPlatForm = (platform: EXTENDED_PLATFORM_TYPE) => {
return getFleetServerHostsEnrollArgs({
apiKey,
fleetServerHost,
platform,
fleetProxy,
showInstallServers,
});
};
const downloadBaseUrl = getDownloadBaseUrl(downloadSource);
const fleetServerUrl = enrollArgs?.split('--url=')?.pop()?.split('--enrollment')[0];
const enrollmentToken = enrollArgs?.split('--enrollment-token=')[1];
const k8sCommand = 'kubectl apply -f elastic-agent-managed-kubernetes.yml';
const { windows: windowsDownloadSourceProxyArgs, curl: curlDownloadSourceProxyArgs } =
getDownloadSourceProxyArgs(downloadSourceProxy);
const debOrRpmWithInstallServers = showInstallServers ? `ELASTIC_AGENT_FLAVOR=servers ` : '';
const linuxAarch64Command = `curl -L -O ${downloadBaseUrl}/beats/elastic-agent/elastic-agent-${agentVersion}-linux-arm64.tar.gz ${curlDownloadSourceProxyArgs}
tar xzvf elastic-agent-${agentVersion}-linux-arm64.tar.gz
cd elastic-agent-${agentVersion}-linux-arm64
sudo ./elastic-agent install ${enrollArgs}`;
sudo ./elastic-agent install ${getEnrollArgsByPlatForm('linux_aarch64')}`;
const linuxX8664Command = `curl -L -O ${downloadBaseUrl}/beats/elastic-agent/elastic-agent-${agentVersion}-linux-x86_64.tar.gz ${curlDownloadSourceProxyArgs}
tar xzvf elastic-agent-${agentVersion}-linux-x86_64.tar.gz
cd elastic-agent-${agentVersion}-linux-x86_64
sudo ./elastic-agent install ${enrollArgs}`;
sudo ./elastic-agent install ${getEnrollArgsByPlatForm('linux_x86_64')}`;
const macAarch64Command = `curl -L -O ${downloadBaseUrl}/beats/elastic-agent/elastic-agent-${agentVersion}-darwin-aarch64.tar.gz ${curlDownloadSourceProxyArgs}
tar xzvf elastic-agent-${agentVersion}-darwin-aarch64.tar.gz
cd elastic-agent-${agentVersion}-darwin-aarch64
sudo ./elastic-agent install ${enrollArgs}`;
sudo ./elastic-agent install ${getEnrollArgsByPlatForm('mac_aarch64')}`;
const macX8664Command = `curl -L -O ${downloadBaseUrl}/beats/elastic-agent/elastic-agent-${agentVersion}-darwin-x86_64.tar.gz ${curlDownloadSourceProxyArgs}
tar xzvf elastic-agent-${agentVersion}-darwin-x86_64.tar.gz
cd elastic-agent-${agentVersion}-darwin-x86_64
sudo ./elastic-agent install ${enrollArgs}`;
sudo ./elastic-agent install ${getEnrollArgsByPlatForm('mac_x86_64')}`;
const windowsCommand = `$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri ${downloadBaseUrl}/beats/elastic-agent/elastic-agent-${agentVersion}-windows-x86_64.zip -OutFile elastic-agent-${agentVersion}-windows-x86_64.zip ${windowsDownloadSourceProxyArgs}
Expand-Archive .\\elastic-agent-${agentVersion}-windows-x86_64.zip -DestinationPath .
cd elastic-agent-${agentVersion}-windows-x86_64
.\\elastic-agent.exe install ${enrollArgs}`;
.\\elastic-agent.exe install ${getEnrollArgsByPlatForm('windows')}`;
const windowsMSICommand = `$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri ${downloadBaseUrl}/beats/elastic-agent/elastic-agent-${agentVersion}-windows-x86_64.msi -OutFile elastic-agent-${agentVersion}-windows-x86_64.msi ${windowsDownloadSourceProxyArgs}
.\\elastic-agent.msi --% INSTALLARGS="${enrollArgs}"`;
.\\elastic-agent.msi --% INSTALLARGS="${getEnrollArgsByPlatForm('windows_msi')}"`;
const linuxDebAarch64Command = `curl -L -O ${downloadBaseUrl}/beats/elastic-agent/elastic-agent-${agentVersion}-arm64.deb ${curlDownloadSourceProxyArgs}
sudo dpkg -i elastic-agent-${agentVersion}-arm64.deb
sudo systemctl enable elastic-agent \nsudo systemctl start elastic-agent \nsudo elastic-agent enroll ${enrollArgs} \n`;
sudo ${debOrRpmWithInstallServers}dpkg -i elastic-agent-${agentVersion}-arm64.deb
sudo systemctl enable elastic-agent \nsudo systemctl start elastic-agent \nsudo elastic-agent enroll ${getEnrollArgsByPlatForm(
'deb_aarch64'
)} \n`;
const linuxDebX8664Command = `curl -L -O ${downloadBaseUrl}/beats/elastic-agent/elastic-agent-${agentVersion}-amd64.deb ${curlDownloadSourceProxyArgs}
sudo dpkg -i elastic-agent-${agentVersion}-amd64.deb
sudo systemctl enable elastic-agent \nsudo systemctl start elastic-agent \nsudo elastic-agent enroll ${enrollArgs} \n`;
sudo ${debOrRpmWithInstallServers}dpkg -i elastic-agent-${agentVersion}-amd64.deb
sudo systemctl enable elastic-agent \nsudo systemctl start elastic-agent \nsudo elastic-agent enroll ${getEnrollArgsByPlatForm(
'deb_x86_64'
)} \n`;
const linuxRpmAarch64Command = `curl -L -O ${downloadBaseUrl}/beats/elastic-agent/elastic-agent-${agentVersion}-aarch64.rpm ${curlDownloadSourceProxyArgs}
sudo rpm -vi elastic-agent-${agentVersion}-aarch64.rpm
sudo systemctl enable elastic-agent \nsudo systemctl start elastic-agent \nsudo elastic-agent enroll ${enrollArgs} \n`;
sudo ${debOrRpmWithInstallServers}rpm -vi elastic-agent-${agentVersion}-aarch64.rpm
sudo systemctl enable elastic-agent \nsudo systemctl start elastic-agent \nsudo elastic-agent enroll ${getEnrollArgsByPlatForm(
'rpm_aarch64'
)} \n`;
const linuxRpmX8664Command = `curl -L -O ${downloadBaseUrl}/beats/elastic-agent/elastic-agent-${agentVersion}-x86_64.rpm ${curlDownloadSourceProxyArgs}
sudo rpm -vi elastic-agent-${agentVersion}-x86_64.rpm
sudo systemctl enable elastic-agent \nsudo systemctl start elastic-agent \nsudo elastic-agent enroll ${enrollArgs} \n`;
sudo ${debOrRpmWithInstallServers}rpm -vi elastic-agent-${agentVersion}-x86_64.rpm
sudo systemctl enable elastic-agent \nsudo systemctl start elastic-agent \nsudo elastic-agent enroll ${getEnrollArgsByPlatForm(
'rpm_x86_64'
)} \n`;
// google shell commands
const googleShellEnrollArgs = getEnrollArgsByPlatForm('google_shell');
const googleShellFleetServerUrl = googleShellEnrollArgs
?.split('--url=')
?.pop()
?.split('--enrollment')[0];
const googleShellEnrollmentToken = googleShellEnrollArgs?.split('--enrollment-token=')[1];
const googleCloudShellCommand = `gcloud config set project ${gcpProjectId} && ${
gcpAccountType === 'organization-account' ? `ORG_ID=${gcpOrganizationId}` : ``
} FLEET_URL=${fleetServerUrl?.trim()} ENROLLMENT_TOKEN=${enrollmentToken} STACK_VERSION=${agentVersion} ./deploy.sh`;
} FLEET_URL=${googleShellFleetServerUrl?.trim()} ENROLLMENT_TOKEN=${googleShellEnrollmentToken} STACK_VERSION=${agentVersion} ./deploy.sh`;
return {
linux_aarch64: linuxAarch64Command,

View file

@ -21,12 +21,36 @@ export type PLATFORM_TYPE =
| 'kubernetes'
| 'windows_msi';
export type EXTENDED_PLATFORM_TYPE =
| 'linux_aarch64'
| 'linux_x86_64'
| 'mac_aarch64'
| 'mac_x86_64'
| 'windows'
| 'rpm_aarch64'
| 'rpm_x86_64'
| 'deb_aarch64'
| 'deb_x86_64'
| 'kubernetes'
| 'windows_msi'
| 'google_shell'
| 'cloud_formation';
interface PLATFORM_OPTION {
label: string;
id: PLATFORM_TYPE;
'data-test-subj'?: string;
}
export const PLATFORM_WITH_INSTALL_SERVERS = [
'linux_aarch64',
'linux_x86_64',
'mac_aarch64',
'mac_x86_64',
'windows',
'windows_msi',
];
export const VISIBLE_PLATFORM_OPTIONS: PLATFORM_OPTION[] = [
{
id: 'linux_aarch64',