Following the discussion in Gadget providing serial-port slot, I’m building an image with a custom gadget. So far so good, but I have a few questions about what is and is not possible in terms of pre-configuration of the image. This is all with a view to allowing hassle-free (read: no
console-conf) provisioning of devices.
Namely, is it possible to:
- Have the device skip interactive configuration on first boot. Specifically
- Use a pre-defined default network configuration (e.g. straightforward DHCP on Ethernet port). It looks like there’s a plan to enable this via netplan, but that’s currently on hold (per Standard for bootstrapping network (on Raspberry Pi and similar devices))
- Have a particular SSO user signed into the device on first boot. For instance, in order to allow access to private snaps
- Possibly related to (but not dependent on) the above, create a user account with a given authorized SSH public key that allows console access.
- Set a given environment variable to a certain value. I’m not sure whether creating a
/system-data/etc/environmentfile within the image is a great idea. Or whether setting an environment variable in the gadget snap will have any effect whatsoever.
- Have a particular plug in a pre-installed snap automatically connected to an interface provided by the gadget. From what I understand, the “proper” way to achieve this is to request auto-connection of the snap via this forum, and to also release the gadget to the store and have it approved (based on https://kyrofa.com/posts/ros-production-create-an-ubuntu-core-image-with-our-snap-preinstalled-5-5). Is there maybe a more straightforward way?
From Cloud-init with netplan it sounds like using
cloud-init may be a sensible way to achieve some of this, but I have not looked further into that. Would that be considered best practice? Could hooks also potentially play a role here, such as the
prepare-device gadget hook?
Apologies for the multitude of questions, and big thanks in advance for any pointers!