I’m having issues setting up N8N using a Jelastic JPS template. The main problem is that the environment variable for the PostgreSQL database host isn’t getting the correct IP address automatically.
type: install
id: workflow-automation
version: 1.0
name: Workflow Engine Setup
globals:
database_user: workflow-${fn.random(5000)}
database_pass: ${fn.password}
secret_key: app${fn.password}
nodes:
- nodeType: nginx
displayName: Proxy Server
cloudlets: 8
nodeGroup: proxy
- image: n8nio/n8n:latest
displayName: Workflow Engine
cloudlets: 12
nodeGroup: app
links: database:pg
env:
N8N_BASIC_AUTH_ACTIVE: true
N8N_BASIC_AUTH_USER: ${globals.database_user}
N8N_BASIC_AUTH_PASSWORD: ${globals.database_pass}
N8N_ENCRYPTION_KEY: ${globals.secret_key}
DB_TYPE: postgresdb
DB_POSTGRESDB_DATABASE: workflow
DB_POSTGRESDB_HOST: ${nodes.database[0].address}
DB_POSTGRESDB_PORT: 5432
DB_POSTGRESDB_USER: ${globals.database_user}
DB_POSTGRESDB_PASSWORD: ${globals.database_pass}
- image: postgres:15
cloudlets: 8
nodeGroup: database
displayName: Database Server
env:
POSTGRES_USER: ${globals.database_user}
POSTGRES_PASSWORD: ${globals.database_pass}
POSTGRES_DB: workflow
I tried different ways to reference the database IP but none work:
DB_POSTGRESDB_HOST: ${nodes.database[0].address}
DB_POSTGRESDB_HOST: ${nodes.database.first.address}
DB_POSTGRESDB_HOST: ${nodes.database.master.address}
The issue seems to be timing related. When the environment variables are set, the database node doesn’t exist yet so there’s no IP to assign. How can I set this variable after the database node is created? Any ideas would be helpful.