Skip to content

Commit

Permalink
Revert fleet setup changes & logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
John Schulz committed Apr 7, 2020
1 parent 0ddd227 commit 583284a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 44 deletions.
4 changes: 1 addition & 3 deletions x-pack/plugins/endpoint/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ export class EndpointPlugin
);
}

public start(core: CoreStart, deps: EndpointPluginStartDependencies) {
console.log('endpoint#start', { core, deps }, deps.ingestManager.isInitialized);
}
public start(/* core: CoreStart, deps: EndpointPluginStartDependencies*/) {}

public stop() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,17 @@ import { WithoutHeaderLayout } from '../../../layouts';
export const SetupPage: React.FunctionComponent<{
refresh: () => Promise<void>;
}> = ({ refresh }) => {
console.log('SetupPage');
const [isFormLoading, setIsFormLoading] = useState<boolean>(false);
const core = useCore();

const onSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
setIsFormLoading(true);
try {
// console.log('fleet setup page does POST /fleet/setup');
// await sendRequest({
// method: 'post',
// path: fleetSetupRouteService.postFleetSetupPath(),
// });
await sendRequest({
method: 'post',
path: fleetSetupRouteService.postFleetSetupPath(),
});
await refresh();
} catch (error) {
core.notifications.toasts.addDanger(error.message);
Expand Down
16 changes: 1 addition & 15 deletions x-pack/plugins/ingest_manager/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export class IngestManagerPlugin
}

public setup(core: CoreSetup, deps: IngestManagerSetupDeps) {
console.log('plugin#setup', { core, deps });
const config = this.config;
// Register main Ingest Manager app
core.application.register({
Expand All @@ -58,27 +57,14 @@ export class IngestManagerPlugin
IngestManagerStartDeps,
IngestManagerStart
];
console.log('plugin#setup mount()');
const { renderApp } = await import('./applications/ingest_manager');
return renderApp(coreStart, params, deps, startDeps, config);
},
});
}

public async start(core: CoreStart): Promise<IngestManagerStart> {
const config = this.config;
core.http.post('/api/ingest_manager/setup');

let isInitialized = false;
if (config.fleet.enabled) {
const results = await core.http.get('/api/ingest_manager/fleet/setup');
console.log({ results });
if (!results.isInitialized) {
const retry = await core.http.post('/api/ingest_manager/fleet/setup');
console.log({ retry });
}
isInitialized = results.isInitialized;
}
const { isInitialized } = await core.http.post('/api/ingest_manager/setup');

return { isInitialized };
}
Expand Down
4 changes: 0 additions & 4 deletions x-pack/plugins/ingest_manager/server/routes/setup/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ export const createFleetSetupHandler: RequestHandler = async (context, request,
try {
const soClient = context.core.savedObjects.client;
const callCluster = context.core.elasticsearch.adminClient.callAsCurrentUser;
// console.log('createFleetSetupHandler setupIngest');
// await setupIngestManager(soClient, callCluster);
console.log('createFleetSetupHandler setupFleet');
await setupFleet(soClient, callCluster);

return response.ok({
Expand All @@ -54,7 +51,6 @@ export const ingestManagerSetupHandler: RequestHandler = async (context, request
const soClient = context.core.savedObjects.client;
const callCluster = context.core.elasticsearch.adminClient.callAsCurrentUser;
try {
console.log('ingestManagerSetupHandler setupIngest');
await setupIngestManager(soClient, callCluster);
return response.ok({
body: { isInitialized: true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ export async function createAPIKey(
name: string,
roleDescriptors: any
) {
console.log('createAPIKey', { name, roleDescriptors });
const adminUser = await outputService.getAdminUser(soClient);
console.log({ adminUser });
if (!adminUser) {
throw new Error('No admin user configured');
}
Expand Down
22 changes: 8 additions & 14 deletions x-pack/plugins/ingest_manager/server/services/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,35 +84,29 @@ export async function setupFleet(
],
},
});
console.log('created fleet_enroll roll');

const password = generateRandomPassword();
// Create fleet enroll user
const a = await callCluster('transport.request', {
await callCluster('transport.request', {
method: 'PUT',
path: `/_security/user/${FLEET_ENROLL_USERNAME}`,
body: {
password,
roles: [FLEET_ENROLL_ROLE],
},
});
console.log('created fleet_enroll user', a);

// save fleet admin user
const b = await outputService.updateOutput(
soClient,
await outputService.getDefaultOutputId(soClient),
{
fleet_enroll_username: FLEET_ENROLL_USERNAME,
fleet_enroll_password: password,
}
);
console.log('created fleet admin user', b);
await outputService.updateOutput(soClient, await outputService.getDefaultOutputId(soClient), {
fleet_enroll_username: FLEET_ENROLL_USERNAME,
fleet_enroll_password: password,
});

// Generate default enrollment key
const c = await generateEnrollmentAPIKey(soClient, {
await generateEnrollmentAPIKey(soClient, {
name: 'Default',
configId: await agentConfigService.getDefaultAgentConfigId(soClient),
});
console.log('generatged default enrollment key', c);
}

function generateRandomPassword() {
Expand Down

0 comments on commit 583284a

Please sign in to comment.