fixed rpm and deb instructions (#133764)

This commit is contained in:
Julia Bardi 2022-06-07 17:34:51 +02:00 committed by GitHub
parent de3410eedd
commit 7e3cdb92b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 55 deletions

View file

@ -70,11 +70,12 @@ describe('getInstallCommandForPlatform', () => {
expect(res).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--x86_64.rpm
tar xzvf elastic-agent--x86_64.rpm
cd elastic-agent--x86_64
sudo rpm -vi elastic-agent--x86_64.rpm
sudo elastic-agent enroll \\\\
--fleet-server-es=http://elasticsearch:9200 \\\\
--fleet-server-service-token=service-token-1"
--fleet-server-service-token=service-token-1
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent"
`);
});
@ -87,11 +88,12 @@ describe('getInstallCommandForPlatform', () => {
expect(res).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--amd64.deb
tar xzvf elastic-agent--amd64.deb
cd elastic-agent--amd64
sudo dpkg -i elastic-agent--amd64.deb
sudo elastic-agent enroll \\\\
--fleet-server-es=http://elasticsearch:9200 \\\\
--fleet-server-service-token=service-token-1"
--fleet-server-service-token=service-token-1
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent"
`);
});
@ -187,12 +189,13 @@ describe('getInstallCommandForPlatform', () => {
expect(res).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--x86_64.rpm
tar xzvf elastic-agent--x86_64.rpm
cd elastic-agent--x86_64
sudo rpm -vi elastic-agent--x86_64.rpm
sudo elastic-agent enroll \\\\
--fleet-server-es=http://elasticsearch:9200 \\\\
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-policy=policy-1"
--fleet-server-policy=policy-1
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent"
`);
});
@ -206,12 +209,13 @@ describe('getInstallCommandForPlatform', () => {
expect(res).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--amd64.deb
tar xzvf elastic-agent--amd64.deb
cd elastic-agent--amd64
sudo dpkg -i elastic-agent--amd64.deb
sudo elastic-agent enroll \\\\
--fleet-server-es=http://elasticsearch:9200 \\\\
--fleet-server-service-token=service-token-1 \\\\
--fleet-server-policy=policy-1"
--fleet-server-policy=policy-1
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent"
`);
});
});
@ -305,8 +309,7 @@ describe('getInstallCommandForPlatform', () => {
expect(res).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--x86_64.rpm
tar xzvf elastic-agent--x86_64.rpm
cd elastic-agent--x86_64
sudo rpm -vi elastic-agent--x86_64.rpm
sudo elastic-agent enroll --url=http://fleetserver:8220 \\\\
--fleet-server-es=http://elasticsearch:9200 \\\\
--fleet-server-service-token=service-token-1 \\\\
@ -314,7 +317,9 @@ describe('getInstallCommandForPlatform', () => {
--certificate-authorities=<PATH_TO_CA> \\\\
--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-cert-key=<PATH_TO_FLEET_SERVER_CERT_KEY>
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent"
`);
});
@ -330,8 +335,7 @@ describe('getInstallCommandForPlatform', () => {
expect(res).toMatchInlineSnapshot(`
"curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--amd64.deb
tar xzvf elastic-agent--amd64.deb
cd elastic-agent--amd64
sudo dpkg -i elastic-agent--amd64.deb
sudo elastic-agent enroll --url=http://fleetserver:8220 \\\\
--fleet-server-es=http://elasticsearch:9200 \\\\
--fleet-server-service-token=service-token-1 \\\\
@ -339,7 +343,9 @@ describe('getInstallCommandForPlatform', () => {
--certificate-authorities=<PATH_TO_CA> \\\\
--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-cert-key=<PATH_TO_FLEET_SERVER_CERT_KEY>
sudo systemctl enable elastic-agent
sudo systemctl start elastic-agent"
`);
});
});

View file

@ -14,34 +14,40 @@ export type CommandsByPlatform = {
function getArtifact(platform: PLATFORM_TYPE, kibanaVersion: string) {
const ARTIFACT_BASE_URL = 'https://artifacts.elastic.co/downloads/beats/elastic-agent';
const artifactMap: Record<
PLATFORM_TYPE,
{ fullUrl: string; filename: string; unpackedDir: string }
> = {
const artifactMap: Record<PLATFORM_TYPE, { downloadCommand: string }> = {
linux: {
fullUrl: `${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-linux-x86_64.tar.gz`,
filename: `elastic-agent-${kibanaVersion}-linux-x86_64.tar.gz`,
unpackedDir: `elastic-agent-${kibanaVersion}-linux-x86_64`,
downloadCommand: [
`curl -L -O ${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-linux-x86_64.tar.gz`,
`tar xzvf elastic-agent-${kibanaVersion}-linux-x86_64.tar.gz`,
`cd elastic-agent-${kibanaVersion}-linux-x86_64`,
].join(`\n`),
},
mac: {
fullUrl: `${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-darwin-x86_64.tar.gz`,
filename: `elastic-agent-${kibanaVersion}-darwin-x86_64.tar.gz`,
unpackedDir: `elastic-agent-${kibanaVersion}-darwin-x86_64`,
downloadCommand: [
`curl -L -O ${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-darwin-x86_64.tar.gz`,
`tar xzvf elastic-agent-${kibanaVersion}-darwin-x86_64.tar.gz`,
`cd elastic-agent-${kibanaVersion}-darwin-x86_64`,
].join(`\n`),
},
windows: {
fullUrl: `${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-windows-x86_64.zip`,
filename: `elastic-agent-${kibanaVersion}-windows-x86_64.zip`,
unpackedDir: `elastic-agent-${kibanaVersion}-windows-x86_64`,
downloadCommand: [
`$ProgressPreference = 'SilentlyContinue'`,
`wget ${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-windows-x86_64.zip -OutFile elastic-agent-${kibanaVersion}-windows-x86_64.zip`,
`Expand-Archive .\\elastic-agent-${kibanaVersion}-windows-x86_64.zip`,
`cd elastic-agent-${kibanaVersion}-windows-x86_64`,
].join(`\n`),
},
deb: {
fullUrl: `${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-amd64.deb`,
filename: `elastic-agent-${kibanaVersion}-amd64.deb`,
unpackedDir: `elastic-agent-${kibanaVersion}-amd64`,
downloadCommand: [
`curl -L -O ${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-amd64.deb`,
`sudo dpkg -i elastic-agent-${kibanaVersion}-amd64.deb`,
].join(`\n`),
},
rpm: {
fullUrl: `${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-x86_64.rpm`,
filename: `elastic-agent-${kibanaVersion}-x86_64.rpm`,
unpackedDir: `elastic-agent-${kibanaVersion}-x86_64`,
downloadCommand: [
`curl -L -O ${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-x86_64.rpm`,
`sudo rpm -vi elastic-agent-${kibanaVersion}-x86_64.rpm`,
].join(`\n`),
},
};
@ -61,19 +67,6 @@ export function getInstallCommandForPlatform(
const newLineSeparator = platform === 'windows' ? '`\n' : '\\\n';
const artifact = getArtifact(platform, kibanaVersion ?? '');
const downloadCommand =
platform === 'windows'
? [
"$ProgressPreference = 'SilentlyContinue'",
`wget ${artifact.fullUrl} -OutFile ${artifact.filename}`,
`Expand-Archive .\\${artifact.filename}`,
`cd ${artifact.unpackedDir}`,
].join(`\n`)
: [
`curl -L -O ${artifact.fullUrl}`,
`tar xzvf ${artifact.filename}`,
`cd ${artifact.unpackedDir}`,
].join(`\n`);
const commandArguments = [];
@ -109,11 +102,11 @@ export function getInstallCommandForPlatform(
}, '');
const commands = {
linux: `${downloadCommand}\nsudo ./elastic-agent install${commandArgumentsStr}`,
mac: `${downloadCommand}\nsudo ./elastic-agent install ${commandArgumentsStr}`,
windows: `${downloadCommand}\n.\\elastic-agent.exe install ${commandArgumentsStr}`,
deb: `${downloadCommand}\nsudo elastic-agent enroll ${commandArgumentsStr}`,
rpm: `${downloadCommand}\nsudo elastic-agent enroll ${commandArgumentsStr}`,
linux: `${artifact.downloadCommand}\nsudo ./elastic-agent install${commandArgumentsStr}`,
mac: `${artifact.downloadCommand}\nsudo ./elastic-agent install ${commandArgumentsStr}`,
windows: `${artifact.downloadCommand}\n.\\elastic-agent.exe install ${commandArgumentsStr}`,
deb: `${artifact.downloadCommand}\nsudo elastic-agent enroll ${commandArgumentsStr}\nsudo systemctl enable elastic-agent\nsudo systemctl start elastic-agent`,
rpm: `${artifact.downloadCommand}\nsudo elastic-agent enroll ${commandArgumentsStr}\nsudo systemctl enable elastic-agent\nsudo systemctl start elastic-agent`,
};
return commands[platform];