Provision Configurations for Brokers, Database on startup

In Node-RED, is there a way to provision Credentials to MQTT broker or certain databases via settings or a configuration file so that they are available in Node-RED when it is brought up / Docker container is spun up?

I have a tool that does provisioning of such containers prior to them starting up with the exception of node-RED where beyond the user credentials I have no other thing I can provision node-RED with.

See Using environment variables : Node-RED

Thanks for this steve. I am a bit curious whether one can use the environment variables to say, configure the MQTT Config Node beforehand. I have a provisioning tool that sets up an MQTT Broker with credentials and my Aim is upon dragging an MQTT in / out node one does not need to configure it but use it right away with the aforementioned credentials.

This video does a decent job of explaining how to use Env Vars in Flows Getting configuration from the environment for a Node-RED application deployed to cloud - YouTube

However, from what I understand that a flow is required beforehand and just setting the MQTT Config is not possible.

This is not possible. Typically*, a node does not use default values - they must be set.

You could however add an MQTT config node, preconfigured with the determined ENV VARS ready for use. The user then simply drags an MQTT node onto the form and it should select the first available MQTT config.

Also,
You could always deploy a basic "informational" flow with your image that lists out the ENV VARS (and how to use them).

You could however add an MQTT config node, preconfigured with the determined ENV VARS ready for use. The user then simply drags an MQTT node onto the form and it should select the first available MQTT config.

This is done via setting the flows.json file or is there a better way of doing this?

Add it in the editor via an MQTT-n/out node, then delete the MQTT node (leaving the MQTT config node)

or just export the JSON for the config node

or export it all and remove the MQTT node

Several ways better than manually creating JSON

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.