Hello, I am trying to implement n8n with a JPS manifest, but I have the problem that n8n does not detect the DB_POSTGRESDB_HOST environment variable and I need to pass the ip of the postgres node to that variable with ${nodes.sqldb[0].address } It only works when I have manually implemented and added that variable and its value from the graphical interface but I have not been able to pass that variable to it from the JPS, not even by writing a random IP to see if it detects it. Does anybody know what is it due to? Thank you so much.
type: install
id: n8n-workflow
version: 1.0
name: n8n Workflow Automation
homepage: https://n8n.io/
logo: https://asset.brandfetch.io/idO6_6uqJ9/id-H5HD3pX.png?updated=1655217178680
globals:
db_user: n8n-${fn.random(1000)}
db_pswd: ${fn.password}
encryption_key: n8n${fn.password}
targetRegions:
type: [ vz.*, pcs.* ]
categories:
- apps/automation
- apps/popular
onBeforeInit: |
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.GetMethod;
var client = new HttpClient(),
getMethod,
response,
status,
resp,
url;
url = "https://registry.hub.docker.com/v2/repositories/n8nio/n8n/tags";
getMethod = new GetMethod(url);
status = client.executeMethod(getMethod);
resp = getMethod.getResponseBodyAsString();
resp = JSON.parse(resp);
tags = resp.results;
var ver = {};
var def = "latest";
var tag;
for (var i = 0, n = tags.length; i < n; i++) {
tag = tags[i].name;
if (tag) {
ver[tag] = tag;
def = tag;
}
}
return {
result: 0,
settings: {
fields: [{
name: "version",
caption: "n8n Version",
type: "list",
values: ver,
"default": def
}]
}
};
ssl: true
nodes:
- nodeType: nginx
displayName: Load Balancer
cloudlets: 16
nodeGroup: bl
- image: n8nio/n8n:${settings.version}
displayName: n8n
cloudlets: 16
nodeGroup: cp
links: sqldb:db
startServiceOnCreation: true
env:
N8N_BASIC_AUTH_ACTIVE: true
N8N_BASIC_AUTH_USER: ${globals.db_user}
N8N_BASIC_AUTH_PASSWORD: ${globals.db_pswd}
WEBHOOK_TUNNEL_URL: ${env.url}
N8N_ENCRYPTION_KEY: ${globals.encryption_key}
DB_TYPE: postgresdb
DB_POSTGRESDB_DATABASE: n8n
DB_POSTGRESDB_HOST: ${nodes.sqldb[0].address}
DB_POSTGRESDB_PORT: 5432
DB_POSTGRESDB_USER: ${globals.db_user}
DB_POSTGRESDB_PASSWORD: ${globals.db_pswd}
- image: postgres:16.2
cloudlets: 16
nodeGroup: sqldb
displayName: PostgreSQL DB
env:
POSTGRES_USER: ${globals.db_user}
POSTGRES_PASSWORD: ${globals.db_pswd}
POSTGRES_DB: n8n
onInstall:
- if ('${env.protocol}' == 'https'):
cmd[bl]: |-
CONF_FILE="/etc/nginx/nginx-jelastic.conf"
sed -i ':a;$!{N;ba};s/\\(location \\/ {\\)/\\1\\n\\n\\t\\t\\t\\t\\t\\tif ($http_x_forwarded_proto = http) {\\n\\t\\t\\t\\t\\t\\t\\t\\treturn 302 https:\\/\\/$host$request_uri;\\n\\t\\t\\t\\t\\t\\t\\t\\terror_page 500 502 503 504 = @rescue;\\n\\t\\t\\t\\t\\t\\t}\\n/1' "$CONF_FILE"
sed -i -r 's/(:80)\$ common;/:5678\$ common;/' "$CONF_FILE"
sed -i -r 's/(server[[:space:]]+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)(;)/\1:5678\2/g' "$CONF_FILE"
sed -i -r 's/(server[[:space:]]+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+))[[:space:]]*;/\1:5678;/' "$CONF_FILE"
service nginx restart
user: root
- restartNode:
nodeGroup: "cp"
reboot: true
success: |-
n8n Workflow Automation is ready to use. Please open [${env.url}](${env.url}) to configure your workflows.
**Username:** ${globals.db_user}
**Password:** ${globals.db_pswd}