From 37b7ee28479b25dfc68d0b28b559faa0f08dddee Mon Sep 17 00:00:00 2001 From: Ryan Hass Date: Wed, 9 Oct 2024 11:35:10 -0700 Subject: [PATCH] [8.15] Fix order of operations in instructions. (#195503) (#195605) # Backport This will backport the following commits from `main` to `8.15`: - [Fix order of operations in instructions. (#195503)](https://github.com/elastic/kibana/pull/195503) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) \n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sqren/backport)\n\n\n\nCo-authored-by: Ryan Hass "}}]}] BACKPORT--> --- .../utils/install_command_utils.test.ts | 36 +++++++++---------- .../utils/install_command_utils.ts | 4 +-- .../enrollment_instructions/manual/index.tsx | 4 +-- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/fleet_server_instructions/utils/install_command_utils.test.ts b/x-pack/plugins/fleet/public/applications/fleet/components/fleet_server_instructions/utils/install_command_utils.test.ts index 21a2cc53257f7..5000caa69e3e7 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/fleet_server_instructions/utils/install_command_utils.test.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/components/fleet_server_instructions/utils/install_command_utils.test.ts @@ -74,12 +74,12 @@ describe('getInstallCommandForPlatform', () => { expect(res).toMatchInlineSnapshot(` "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--x86_64.rpm sudo rpm -vi elastic-agent--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 - sudo systemctl enable elastic-agent - sudo systemctl start elastic-agent" + --fleet-server-port=8220" `); }); @@ -93,12 +93,12 @@ 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 \\\\ --fleet-server-es=http://elasticsearch:9200 \\\\ --fleet-server-service-token=service-token-1 \\\\ - --fleet-server-port=8220 - sudo systemctl enable elastic-agent - sudo systemctl start elastic-agent" + --fleet-server-port=8220" `); }); @@ -199,13 +199,13 @@ describe('getInstallCommandForPlatform', () => { expect(res).toMatchInlineSnapshot(` "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--x86_64.rpm sudo rpm -vi elastic-agent--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 - sudo systemctl enable elastic-agent - sudo systemctl start elastic-agent" + --fleet-server-port=8220" `); }); @@ -220,13 +220,13 @@ 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 \\\\ --fleet-server-es=http://elasticsearch:9200 \\\\ --fleet-server-service-token=service-token-1 \\\\ --fleet-server-policy=policy-1 \\\\ - --fleet-server-port=8220 - sudo systemctl enable elastic-agent - sudo systemctl start elastic-agent" + --fleet-server-port=8220" `); }); }); @@ -356,6 +356,8 @@ describe('getInstallCommandForPlatform', () => { expect(res).toMatchInlineSnapshot(` "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--x86_64.rpm sudo rpm -vi elastic-agent--x86_64.rpm + 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 \\\\ @@ -364,9 +366,7 @@ describe('getInstallCommandForPlatform', () => { --fleet-server-es-ca= \\\\ --fleet-server-cert= \\\\ --fleet-server-cert-key= \\\\ - --fleet-server-port=8220 - sudo systemctl enable elastic-agent - sudo systemctl start elastic-agent" + --fleet-server-port=8220" `); }); @@ -383,6 +383,8 @@ 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 \\\\ @@ -391,9 +393,7 @@ describe('getInstallCommandForPlatform', () => { --fleet-server-es-ca= \\\\ --fleet-server-cert= \\\\ --fleet-server-cert-key= \\\\ - --fleet-server-port=8220 - sudo systemctl enable elastic-agent - sudo systemctl start elastic-agent" + --fleet-server-port=8220" `); }); }); diff --git a/x-pack/plugins/fleet/public/applications/fleet/components/fleet_server_instructions/utils/install_command_utils.ts b/x-pack/plugins/fleet/public/applications/fleet/components/fleet_server_instructions/utils/install_command_utils.ts index 79809b94470e4..5158483cdb1f3 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/components/fleet_server_instructions/utils/install_command_utils.ts +++ b/x-pack/plugins/fleet/public/applications/fleet/components/fleet_server_instructions/utils/install_command_utils.ts @@ -124,8 +124,8 @@ export function getInstallCommandForPlatform( 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`, + deb: `${artifact.downloadCommand}\nsudo systemctl enable elastic-agent\nsudo systemctl start elastic-agent\nsudo elastic-agent enroll ${commandArgumentsStr}`, + rpm: `${artifact.downloadCommand}\nsudo systemctl enable elastic-agent\nsudo systemctl start elastic-agent\nsudo elastic-agent enroll ${commandArgumentsStr}`, kubernetes: '', cloudFormation: '', googleCloudShell: '', diff --git a/x-pack/plugins/fleet/public/components/enrollment_instructions/manual/index.tsx b/x-pack/plugins/fleet/public/components/enrollment_instructions/manual/index.tsx index e5733983dd754..df0000681c576 100644 --- a/x-pack/plugins/fleet/public/components/enrollment_instructions/manual/index.tsx +++ b/x-pack/plugins/fleet/public/components/enrollment_instructions/manual/index.tsx @@ -72,11 +72,11 @@ cd elastic-agent-${agentVersion}-windows-x86_64 const linuxDebCommand = `curl -L -O ${downloadBaseUrl}/beats/elastic-agent/elastic-agent-${agentVersion}-amd64.deb sudo dpkg -i elastic-agent-${agentVersion}-amd64.deb -sudo elastic-agent enroll ${enrollArgs} \nsudo systemctl enable elastic-agent \nsudo systemctl start elastic-agent`; +sudo systemctl enable elastic-agent \nsudo systemctl start elastic-agent \nsudo elastic-agent enroll ${enrollArgs} \n`; const linuxRpmCommand = `curl -L -O ${downloadBaseUrl}/beats/elastic-agent/elastic-agent-${agentVersion}-x86_64.rpm sudo rpm -vi elastic-agent-${agentVersion}-x86_64.rpm -sudo elastic-agent enroll ${enrollArgs} \nsudo systemctl enable elastic-agent \nsudo systemctl start elastic-agent`; +sudo systemctl enable elastic-agent \nsudo systemctl start elastic-agent \nsudo elastic-agent enroll ${enrollArgs} \n`; const googleCloudShellCommand = `gcloud config set project ${gcpProjectId} && ${ gcpAccountType === 'organization-account' ? `ORG_ID=${gcpOrganizationId}` : ``