Custom snap auto-connect network-manager slot

I have a custom Ubuntu Core model with a custom snap that requires the network-manager connection at initial boot time. This slot is marked as “Auto-connect: no” which is annoying. The custom snap is not going into the snap store. I just want it to run once at startup and part of its function is to create a new network connection.

After boot I can add the plug/slot connection manually and the app works. I just need to do this automatically,

Is there a way I can do this?

Have a look at https://documentation.ubuntu.com/core/reference/gadget-snap-format/, specifically interface connections which run on first boot.

Thanks but unfortunately this doesn’t work either.

Well, you usually have two options to achieve auto connections on Core, one is to add an override to your brand store for a specific package, the other is the gadget.yaml via the connections block…

There are sadly no other methods, why does using a side-loaded gadget not work for you, is your application not in the store so it has no snap ID ?

EDIT: oh, blind me, you said it is not in the store… There’s a third method via landscape though, but you would indeed have to pre-install the landscape client in your image and have it hook up to a landscape server instance, then you could have a simple script utilize the snapd REST API to establish the connection…

My colleague suggested a solution which I have now implemented and it works. Basically the service uses SSH to connect to localhost and executes the snap connect ... command thus escaping its own context limitations.