balena-os/os-config

Allow to provide default values in os-config.json

Closed this issue · 9 comments

It would be useful to me to be able to provide a default value is os-config.json, just in case the remote os-config server is down, or does not exist yet, or when the device is not directly connected to the internet.
For example this would allow us to put a default ssh public key in /home/root/.ssh/authorized_keys_remote even if no remote os-config server is running.

Would you accept such a feature request? I would like to provide a pull request if you think it can be accepted, but I will need to learn Rust first ;-)

@bbinet That would be nice. I raised it for an internal discussion for possible ways to achieve that for next week. Please let us know if you have any ideas or preferences so that we include them in the discussion.

@majorz Great, thank you.
I don't have any special ideas, but that could simply be a new "default" optional property that can be added to the os-config.json file here: https://github.com/balena-os/meta-balena/blob/master/meta-resin-common/recipes-core/os-config/os-config/os-config.json#L22

Hi @bbinet, sorry to get back to you on this a bit later. We discussed this and we would like to gather more input from you about this.

You mentioned a default public keys support, and we have this through an alternative mechanism: https://github.com/balena-os/meta-balena#sshkeys

Will that solve the issue for you? Please let us know if you have additional ideas.

Hi @majorz, actually I'm also using https://github.com/balena-os/meta-balena#sshkeys and it helps, but the use case here is slightly different: instead of updating the config.json file (to set a custom sshKey value) one by one for every devices we manage, this new feature would allow to create images bundled with default ssh authorized_key even in case the remote os-config server is not available.

@bbinet I missed your latest comment.. You may bake in the ssh key into the config.json in the image itself. And then you may flash it on any number of devices you want. Thus you do not have to update the config.json file one by one for every device. Please let me know if I did not understood you well.

Hi @majorz, actually I think your proposal should work for me, thanks.

@bbinet great, closing the issue in that case.

@majorz Do you know how I could update config.json file directly in the resinos img.xz file?

A quick research points me to kpartx, which seems to do the job if I decompress the image file first: https://superuser.com/questions/344899/how-can-i-mount-a-disk-image

@majorz If you know any better way to do it, don't hesitate to ping me :)