Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature fleet enrollment instructions #65176

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { ShellEnrollmentInstructions } from './shell';
export { ManualInstructions } from './manual';
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,53 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { EuiText, EuiSpacer } from '@elastic/eui';
import React from 'react';
import { EuiText, EuiSpacer, EuiCode, EuiCodeBlock, EuiCopy, EuiButton } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { EnrollmentAPIKey } from '../../../types';

export const ManualInstructions: React.FunctionComponent = () => {
interface Props {
kibanaUrl: string;
apiKey: EnrollmentAPIKey;
kibanaCASha256?: string;
}

export const ManualInstructions: React.FunctionComponent<Props> = ({
kibanaUrl,
apiKey,
kibanaCASha256,
}) => {
const command = `
./elastic-agent enroll ${kibanaUrl} ${apiKey.api_key}${
kibanaCASha256 ? ` --ca_sha256=${kibanaCASha256}` : ''
}
./elastic-agent run`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need sudo or a note about running these commands as root?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should not run these as root

Copy link
Contributor

@jen-huang jen-huang May 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think with recent agent changes @michalpristas said that it needs to be run as root because agent performs chown, chmod, etc actions

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok I was not aware of that, if @ph or @michalpristas can confirm the agent need to be runned as root I can add a sudo here

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

atm we made changes so it can run without sudo. these chown chmod operations were performed at /var/run level before. we changed that so you should not need root.
maybe a thing to point out is that user which runs the agent will be used to run beats as well.

return (
<>
<EuiText>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam vestibulum ullamcorper
turpis vitae interdum. Maecenas orci magna, auctor volutpat pellentesque eu, consectetur id
est. Nunc orci lacus, condimentum vel congue ac, fringilla eget tortor. Aliquam blandit,
nisi et congue euismod, leo lectus blandit risus, eu blandit erat metus sit amet leo. Nam
dictum lobortis condimentum.
<FormattedMessage
id="xpack.ingestManager.enrollmentInstructions.descriptionText"
defaultMessage="From the agent’s directory, run these commands to enroll and start the Elastic Agent. {enrollCommand} will write to your agent’s configuration file so that it has the correct settings. You can use this command to setup agents on more than one host."
values={{
enrollCommand: <EuiCode>agent enroll</EuiCode>,
}}
/>
</EuiText>
<EuiSpacer size="m" />
<EuiText>
Vivamus sem sapien, dictum eu tellus vel, rutrum aliquam purus. Cras quis cursus nibh.
Aliquam fermentum ipsum nec turpis luctus lobortis. Nulla facilisi. Etiam nec fringilla
urna, sed vehicula ipsum. Quisque vel pellentesque lorem, at egestas enim. Nunc semper elit
lectus, in sollicitudin erat fermentum in. Pellentesque tempus massa eget purus pharetra
blandit.
</EuiText>
<EuiCodeBlock fontSize="m">
<pre>{command}</pre>
</EuiCodeBlock>
<EuiSpacer size="m" />
<EuiText>
Mauris congue enim nulla, nec semper est posuere non. Donec et eros eu nisi gravida
malesuada eget in velit. Morbi placerat semper euismod. Suspendisse potenti. Morbi quis
porta erat, quis cursus nulla. Aenean mauris lorem, mollis in mattis et, lobortis a lectus.
</EuiText>
<EuiCopy textToCopy={command}>
{copy => (
<EuiButton iconType="copy" fill onClick={copy}>
<FormattedMessage
id="xpack.ingestManager.enrollmentInstructions.copyButton"
defaultMessage="Copy command"
/>
</EuiButton>
)}
</EuiCopy>
</>
);
};

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,9 @@

import React, { memo } from 'react';
import { dump } from 'js-yaml';
import { FormattedMessage } from '@kbn/i18n/react';
import {
EuiTitle,
EuiSpacer,
EuiText,
EuiCodeBlock,
EuiFlexGroup,
EuiFlexItem,
} from '@elastic/eui';
import { EuiCodeBlock, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { AgentConfig } from '../../../../../types';
import {
useGetOneAgentConfigFull,
useGetEnrollmentAPIKeys,
useGetOneEnrollmentAPIKey,
useCore,
} from '../../../../../hooks';
import { ShellEnrollmentInstructions } from '../../../../../components/enrollment_instructions';
import { useGetOneAgentConfigFull } from '../../../../../hooks';
import { Loading } from '../../../../../components';

const CONFIG_KEYS_ORDER = [
Expand All @@ -38,14 +24,7 @@ const CONFIG_KEYS_ORDER = [
];

export const ConfigYamlView = memo<{ config: AgentConfig }>(({ config }) => {
const core = useCore();

const fullConfigRequest = useGetOneAgentConfigFull(config.id);
const apiKeysRequest = useGetEnrollmentAPIKeys({
page: 1,
perPage: 1000,
});
const apiKeyRequest = useGetOneEnrollmentAPIKey(apiKeysRequest.data?.list?.[0]?.id);

if (fullConfigRequest.isLoading && !fullConfigRequest.data) {
return <Loading />;
Expand All @@ -72,30 +51,6 @@ export const ConfigYamlView = memo<{ config: AgentConfig }>(({ config }) => {
})}
</EuiCodeBlock>
</EuiFlexItem>
{apiKeyRequest.data && (
<EuiFlexItem grow={3}>
<EuiTitle size="s">
<h3>
<FormattedMessage
id="xpack.ingestManager.yamlConfig.instructionTittle"
defaultMessage="Enroll with fleet"
/>
</h3>
</EuiTitle>
<EuiSpacer size="m" />
<EuiText size="s">
<FormattedMessage
id="xpack.ingestManager.yamlConfig.instructionDescription"
defaultMessage="To enroll an agent with this configuration, copy and run the following command on your host."
/>
</EuiText>
<EuiSpacer size="m" />
<ShellEnrollmentInstructions
apiKey={apiKeyRequest.data.item}
kibanaUrl={`${window.location.origin}${core.http.basePath.get()}`}
/>
</EuiFlexItem>
)}
</EuiFlexGroup>
);
});

This file was deleted.

Loading