How to automate onboarding on a self hosted Postgres

I recently started hosting my own n8n instance using this helm charts via k8s: GitHub - 8gears/n8n-helm-chart: A Kubernetes Helm chart for n8n a Workflow Automation Tool. Easily automate tasks across different services.

As we are all automation fans here, this is a nice hack on how to automate the automated installation a bit more.

How to bypass the user creation / nagg screen when installing?

This can be done by a simple sql statement (I am using postgres)

CREATE EXTENSION IF NOT EXISTS pgcrypto;

INSERT INTO public.settings
VALUES('userManagement.isInstanceOwnerSetUp','true', 't')
ON CONFLICT(key) DO
UPDATE SET (key, value, "loadOnStartup") = ('userManagement.isInstanceOwnerSetUp', true, 't');

UPDATE public."user"
       SET ( email, "firstName", "lastName", "password", "personalizationAnswers") =
       ( 
         '[email protected]', 'admin', 'admin',	crypt('MySecret#Thing', gen_salt('bf', 8)),
      	 '{"companyType":"saas","role":"business-owner","automationBeneficiary":"myself","companySize":"<20","reportedSource":"google","version":"v4","personalization_survey_submitted_at":"2023-09-30T08:09:51.119Z","personalization_survey_n8n_version":"1.9.0"}'
      	)
WHERE (email IS NULL OR email = '[email protected]') AND "globalRoleId" = 1
`
1 Like

If you need an API key - this can also be automated

-- n8n uses a 80 key alpha numeric string (started with the prefix 'n8n_api_')
-- it can be generated (on linux) by: cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 80 | head -n 1
UPDATE public."user"
       SET "apiKey" =  'n8n_api_f9voy01rhuens52xfoliy0aeb2mdb13zk3mcetn4oao47jj1rvd3sbepw6ps71a7f4ddh5ttu77bnwjj' 
WHERE (email IS NULL OR email = '[email protected]') AND "globalRoleId" = 1;