Adding local snaps to model assertion?

Hei,

I’m trying to build a custom image that contains some local snaps.

I know I can add local snaps to the image during the “imaging” stage via $ ubuntu-image snap my-model.model --snap ./my_snap.snap but I was wondering if it is possible to add local snaps via the model assertion.

From what I see in the model assertion documentation it should be possible to add “local” snaps this way, though it doesn’t go into detail. The relevant section (emphasis mine):

id (optional): id of the snap if assigned by a store. Must be omitted for **local** snaps.

Am I barking up the wrong tree here or is it possible?

Just skip the "id": "<snap-id>" part while listing snap in the model.

1 Like

Ah, slight issue. If I sumply skip the id": "<snap-id> part, I am unable to sign and create the image… The error I am getting is: $ cat model.assertion.json | sudo snap sign -k key > signed.model error: cannot assemble assertion model: "id" of snap "my-local-snap" is mandatory for signed grade model

The definition of the local snap which I am trying to test in the image (in the image json file):

     {
         "name": "my-local-snap",
         "type": "app",
         "default-channel": "latest/stable",
     }

Yes, a model with grade: signed implies that all snaps are indeed signed (asserted), from the docs:

signed (default): no unasserted (unsigned) snaps or snaps not mentioned in the model can appear or be used in the recovery system.

For development purposes you can downgrade the model to grade: dangerous which will allow various tweaks including use of unasserted snaps.

1 Like