# Provision Configurations for Brokers, Database on startup

**URL:** <https://discourse.nodered.org/t/provision-configurations-for-brokers-database-on-startup/79811>\
**Category:** General\
**Tags:** docker\
**Created:** [14 July 2023 08:33 UTC](https://discourse.nodered.org/t/provision-configurations-for-brokers-database-on-startup/79811 "2023-07-14T08:33:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shan](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shan](https://discourse.nodered.org/u/Shan)\
**Post date:** [14 July 2023 08:33 UTC](https://discourse.nodered.org/t/provision-configurations-for-brokers-database-on-startup/79811/1 "2023-07-14T08:33:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [14 July 2023 08:46 UTC](https://discourse.nodered.org/t/provision-configurations-for-brokers-database-on-startup/79811/2 "2023-07-14T08:46:24Z")

</div>

> [@Shan](#):
>
> 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

See [Using environment variables : Node-RED](https://nodered.org/docs/user-guide/environment-variables)

---

<div class="post-metadata">

**Author:** ![Shan](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shan](https://discourse.nodered.org/u/Shan)\
**Post date:** [14 July 2023 08:56 UTC](https://discourse.nodered.org/t/provision-configurations-for-brokers-database-on-startup/79811/3 "2023-07-14T08:56:11Z")

</div>

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](https://www.youtube.com/watch?v=apKR3UhacWI)

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [14 July 2023 09:18 UTC](https://discourse.nodered.org/t/provision-configurations-for-brokers-database-on-startup/79811/4 "2023-07-14T09:18:31Z")

</div>

> [@Shan](#):
>
> 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 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).

---

<div class="post-metadata">

**Author:** ![Shan](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shan](https://discourse.nodered.org/u/Shan)\
**Post date:** [14 July 2023 09:38 UTC](https://discourse.nodered.org/t/provision-configurations-for-brokers-database-on-startup/79811/5 "2023-07-14T09:38:59Z")

</div>

> 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?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [14 July 2023 10:04 UTC](https://discourse.nodered.org/t/provision-configurations-for-brokers-database-on-startup/79811/6 "2023-07-14T10:04:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [28 July 2023 10:04 UTC](https://discourse.nodered.org/t/provision-configurations-for-brokers-database-on-startup/79811/7 "2023-07-28T10:04:40Z")

</div>

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