mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[9.0] [Fleet] show --install-servers
in Add agent flyout if certain inputs are in agent policy (#214136) (#214219)
# Backport This will backport the following commits from `main` to `9.0`: - [[Fleet] show `--install-servers` in Add agent flyout if certain inputs are in agent policy (#214136)](https://github.com/elastic/kibana/pull/214136) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Julia Bardi","email":"90178898+juliaElastic@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-03-12T16:09:07Z","message":"[Fleet] show `--install-servers` in Add agent flyout if certain inputs are in agent policy (#214136)\n\n## Summary\n\nCloses https://github.com/elastic/kibana/issues/211899\n\nShow `--install-servers` in Add agent flyout if agent policy has one of\n`apm, fleet-server, cloudbeat` inputs\n\nCSPM integration:\n<img width=\"1561\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/94fbc6f1-2e9a-4285-a8b9-7e2c3aa1a0ab\"\n/>\n\nAPM integration:\n<img width=\"1561\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/f7567ae3-bd4d-4efd-90d5-08a114178cf2\"\n/>\n\nAgent policy without `--install-servers`:\n<img width=\"1575\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/1571675b-b32c-46be-8c92-d83bb9aa9d12\"\n/>\n\nCloud asset inventory (prerelease):\n<img width=\"1572\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/2ffb275a-5fad-430f-b757-5783e88c3a79\"\n/>\n\n\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"bed491dc1ae9708ff84350bf768c178ac61dce59","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","backport:prev-minor","v9.1.0"],"title":"[Fleet] show `--install-servers` in Add agent flyout if certain inputs are in agent policy","number":214136,"url":"https://github.com/elastic/kibana/pull/214136","mergeCommit":{"message":"[Fleet] show `--install-servers` in Add agent flyout if certain inputs are in agent policy (#214136)\n\n## Summary\n\nCloses https://github.com/elastic/kibana/issues/211899\n\nShow `--install-servers` in Add agent flyout if agent policy has one of\n`apm, fleet-server, cloudbeat` inputs\n\nCSPM integration:\n<img width=\"1561\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/94fbc6f1-2e9a-4285-a8b9-7e2c3aa1a0ab\"\n/>\n\nAPM integration:\n<img width=\"1561\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/f7567ae3-bd4d-4efd-90d5-08a114178cf2\"\n/>\n\nAgent policy without `--install-servers`:\n<img width=\"1575\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/1571675b-b32c-46be-8c92-d83bb9aa9d12\"\n/>\n\nCloud asset inventory (prerelease):\n<img width=\"1572\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/2ffb275a-5fad-430f-b757-5783e88c3a79\"\n/>\n\n\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"bed491dc1ae9708ff84350bf768c178ac61dce59"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/214136","number":214136,"mergeCommit":{"message":"[Fleet] show `--install-servers` in Add agent flyout if certain inputs are in agent policy (#214136)\n\n## Summary\n\nCloses https://github.com/elastic/kibana/issues/211899\n\nShow `--install-servers` in Add agent flyout if agent policy has one of\n`apm, fleet-server, cloudbeat` inputs\n\nCSPM integration:\n<img width=\"1561\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/94fbc6f1-2e9a-4285-a8b9-7e2c3aa1a0ab\"\n/>\n\nAPM integration:\n<img width=\"1561\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/f7567ae3-bd4d-4efd-90d5-08a114178cf2\"\n/>\n\nAgent policy without `--install-servers`:\n<img width=\"1575\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/1571675b-b32c-46be-8c92-d83bb9aa9d12\"\n/>\n\nCloud asset inventory (prerelease):\n<img width=\"1572\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/2ffb275a-5fad-430f-b757-5783e88c3a79\"\n/>\n\n\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"bed491dc1ae9708ff84350bf768c178ac61dce59"}}]}] BACKPORT--> Co-authored-by: Julia Bardi <90178898+juliaElastic@users.noreply.github.com>
This commit is contained in:
parent
9e48d505ea
commit
81d8624c4c
5 changed files with 74 additions and 5 deletions
|
@ -8,6 +8,7 @@
|
|||
import {
|
||||
getRootIntegrations,
|
||||
getRootPrivilegedDataStreams,
|
||||
hasInstallServersInputs,
|
||||
isRootPrivilegesRequired,
|
||||
} from './package_helpers';
|
||||
|
||||
|
@ -119,3 +120,41 @@ describe('getRootIntegrations', () => {
|
|||
expect(res).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('hasInstallServersInputs', () => {
|
||||
it('should return true if any package policy has fleet-server input', () => {
|
||||
const res = hasInstallServersInputs([
|
||||
{
|
||||
inputs: [{ type: 'fleet-server' }],
|
||||
} as any,
|
||||
]);
|
||||
expect(res).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true if any package policy has apm input', () => {
|
||||
const res = hasInstallServersInputs([
|
||||
{
|
||||
inputs: [{ type: 'apm' }],
|
||||
} as any,
|
||||
]);
|
||||
expect(res).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true if any package policy has cloudbeat input', () => {
|
||||
const res = hasInstallServersInputs([
|
||||
{
|
||||
inputs: [{ type: 'cloudbeat/cis_aws' }],
|
||||
} as any,
|
||||
]);
|
||||
expect(res).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false if no package policy has install servers inputs', () => {
|
||||
const res = hasInstallServersInputs([
|
||||
{
|
||||
inputs: [{ type: 'system' }],
|
||||
} as any,
|
||||
]);
|
||||
expect(res).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -42,3 +42,13 @@ export function getRootIntegrations(
|
|||
(pkg) => pkg!.name
|
||||
).map((pkg) => ({ name: pkg!.name, title: pkg!.title }));
|
||||
}
|
||||
|
||||
const INSTALL_SERVERS_INPUTS = ['cloudbeat', 'apm', 'fleet-server'];
|
||||
|
||||
export function hasInstallServersInputs(packagePolicies: PackagePolicy[]): boolean {
|
||||
return packagePolicies.some((policy) =>
|
||||
policy.inputs.some(
|
||||
(input) => INSTALL_SERVERS_INPUTS.includes(input.type) || input.type.startsWith('cloudbeat')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,10 @@ import { ManualInstructions } from '../../../../../../../../../components/enroll
|
|||
|
||||
import { KubernetesManifestApplyStep } from '../../../../../../../../../components/agent_enrollment_flyout/steps/run_k8s_apply_command_step';
|
||||
|
||||
import { getRootIntegrations } from '../../../../../../../../../../common/services';
|
||||
import {
|
||||
getRootIntegrations,
|
||||
hasInstallServersInputs,
|
||||
} from '../../../../../../../../../../common/services';
|
||||
|
||||
import type { InstallAgentPageProps } from './types';
|
||||
|
||||
|
@ -64,11 +67,14 @@ export const InstallElasticAgentManagedPageStep: React.FC<InstallAgentPageProps>
|
|||
const isK8s =
|
||||
props.packageInfo.name === 'kubernetes' ? 'IS_KUBERNETES_MULTIPAGE' : 'IS_NOT_KUBERNETES';
|
||||
|
||||
const showInstallServers = hasInstallServersInputs(agentPolicy?.package_policies ?? []);
|
||||
|
||||
const installManagedCommands = ManualInstructions({
|
||||
apiKey: enrollmentAPIKey.api_key,
|
||||
fleetProxy,
|
||||
fleetServerHost,
|
||||
agentVersion: agentVersion || '',
|
||||
showInstallServers,
|
||||
});
|
||||
|
||||
const steps = [
|
||||
|
|
|
@ -11,7 +11,7 @@ import { EuiSteps, EuiLoadingSpinner } from '@elastic/eui';
|
|||
|
||||
import type { EuiContainedStepProps } from '@elastic/eui/src/components/steps/steps';
|
||||
|
||||
import { getRootIntegrations } from '../../../../common/services';
|
||||
import { getRootIntegrations, hasInstallServersInputs } from '../../../../common/services';
|
||||
|
||||
import { getGcpIntegrationDetailsFromAgentPolicy } from '../../cloud_security_posture/services';
|
||||
|
||||
|
@ -177,6 +177,8 @@ export const ManagedSteps: React.FunctionComponent<InstructionProps> = ({
|
|||
const { gcpProjectId, gcpOrganizationId, gcpAccountType } =
|
||||
getGcpIntegrationDetailsFromAgentPolicy(selectedPolicy);
|
||||
|
||||
const showInstallServers = hasInstallServersInputs(agentPolicy?.package_policies ?? []);
|
||||
|
||||
const installManagedCommands = ManualInstructions({
|
||||
apiKey: enrollToken,
|
||||
fleetServerHost,
|
||||
|
@ -187,6 +189,7 @@ export const ManagedSteps: React.FunctionComponent<InstructionProps> = ({
|
|||
gcpProjectId,
|
||||
gcpOrganizationId,
|
||||
gcpAccountType,
|
||||
showInstallServers,
|
||||
});
|
||||
|
||||
const instructionsSteps = useMemo(() => {
|
||||
|
|
|
@ -11,7 +11,8 @@ import type { DownloadSource, FleetProxy } from '../../../types';
|
|||
function getfleetServerHostsEnrollArgs(
|
||||
apiKey: string,
|
||||
fleetServerHost: string,
|
||||
fleetProxy?: FleetProxy
|
||||
fleetProxy?: FleetProxy,
|
||||
showInstallServers: boolean = false
|
||||
) {
|
||||
const proxyHeadersArgs = fleetProxy?.proxy_headers
|
||||
? Object.entries(fleetProxy.proxy_headers).reduce((acc, [proxyKey, proyVal]) => {
|
||||
|
@ -21,7 +22,10 @@ function getfleetServerHostsEnrollArgs(
|
|||
}, '')
|
||||
: '';
|
||||
const proxyArgs = fleetProxy ? ` --proxy-url=${fleetProxy.url}${proxyHeadersArgs}` : '';
|
||||
return `--url=${fleetServerHost || `FLEET_SERVER_HOST`} --enrollment-token=${apiKey}${proxyArgs}`;
|
||||
const showInstallServersArgs = showInstallServers ? ' --install-servers' : '';
|
||||
return `--url=${
|
||||
fleetServerHost || `FLEET_SERVER_HOST`
|
||||
} --enrollment-token=${apiKey}${proxyArgs}${showInstallServersArgs}`;
|
||||
}
|
||||
|
||||
export const getDownloadBaseUrl = (downloadSource?: DownloadSource) => {
|
||||
|
@ -67,6 +71,7 @@ export const ManualInstructions = ({
|
|||
gcpProjectId = '<PROJECT_ID>',
|
||||
gcpOrganizationId = '<ORGANIZATION_ID>',
|
||||
gcpAccountType,
|
||||
showInstallServers,
|
||||
}: {
|
||||
apiKey: string;
|
||||
fleetServerHost: string;
|
||||
|
@ -77,8 +82,14 @@ export const ManualInstructions = ({
|
|||
gcpProjectId?: string;
|
||||
gcpOrganizationId?: string;
|
||||
gcpAccountType?: string;
|
||||
showInstallServers?: boolean;
|
||||
}) => {
|
||||
const enrollArgs = getfleetServerHostsEnrollArgs(apiKey, fleetServerHost, fleetProxy);
|
||||
const enrollArgs = getfleetServerHostsEnrollArgs(
|
||||
apiKey,
|
||||
fleetServerHost,
|
||||
fleetProxy,
|
||||
showInstallServers
|
||||
);
|
||||
const downloadBaseUrl = getDownloadBaseUrl(downloadSource);
|
||||
|
||||
const fleetServerUrl = enrollArgs?.split('--url=')?.pop()?.split('--enrollment')[0];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue