How can interactive mode be disabled for balena cli in order to provide the same workflow when updating to a new balena cli version?
I have used a fully automated jenkins job to prepare balena images for devices using the following commands:
balena config generate --device [hash] --network ethernet --generate-device-api-key --version 2.58.6 --appUpdatePollInterval 10 --output config.json
balena os configure [name].img --device [hash] --version 2.58.6 --config config.json
Allowing for preload of images using:
balena preload [name].img --app [hash] --pin-device-to-release --commit latest --spash-image [name].png --api-token [hash]
All this is working as expected and has been performed using balena-cli-v11.9.7-linux-x64-standalone
This process does not work anymore after updating to version balena-cli-v12.44.14-linux-x64-standalone
When using v12.44.14 the balena os configure
command starts an interactive console request in order to select either ethernet og wifi.
? Network Connection (Use arrow keys)
> ethernet
wifi
This has already been set by balena config generate
.
Need a workaround or fix for this.
Hi
One thing that you can do is to think of changing the way in which you use the CLI. The CLI can be imported in your node.js application - so that you can build your wrapper easily. Is that something that would work for you?
No
I am not using node.js. I am building generic-x86/intel-nuc ubuntu images.
Will the balena cli support non-interactive mode in the future?
@aliasbits, my testing with CLI v12.44.14 suggests that adding the --config-network ethernet
flag to the balena os configure
command would prevent the interactive prompt. The help output sheds some additional light:
$ balena help os configure
...
DESCRIPTION
[...] Configuration settings such as WiFi authentication will be taken from the
following sources, in precedence order:
1. Command-line options like `--config-wifi-ssid`
2. A given `config.json` file specified with the `--config` option.
3. User input through interactive prompts (text menus).
You’re right that you had already provided --network ethernet
to balena config generate
, but a deficiency of the CLI and the present config.json
format means that this selection is not explicitly recorded in the config.json
file. It translates as the absence of wifiSsid
and wifiKey
in config.json
, but such absence can mean either “WiFi is wanted but unconfigured” or “WiFi is not wanted”, hence the prompt or the need to provide --config-network ethernet
to os configure
.
Worse than that, since balenaOS v2 (which is already quite old), the WiFi settings in config.json
(wifiSsid
and wifiKey
entries) are ignored by the OS. balenaOS v2 uses NetworkManager to setup WiFi, and the --system-connection
option can be used to inject connection profiles:
$ balena help os configure
...
DESCRIPTION
The --system-connection (-c) option can be used to inject NetworkManager connection
profiles for additional network interfaces, such as cellular/GSM or additional
WiFi or ethernet connections. This option may be passed multiple times in case there
are multiple files to inject. See connection profile examples and reference at:
https://www.balena.io/docs/reference/OS/network/2.x/
https://developer.gnome.org/NetworkManager/stable/ref-settings.html
In summary, adding the --config-network ethernet
flag to the os configure
command should solve the interactive prompt issue you were facing.
@pdcastro, thank you for the detailed feedback.
Sounds like the --network ethernet
for balena config generate
is depricated.
I will use the --config-network ethernet
for balane os configure
instead.
Thanks