I am preparing incus images using the following workflow:
launch → (tweak) → cloud-init clean → stop → incus publish → incus image export → simplestreams
This works fine but I have one problem: the tweaked configuration has a custom /etc/hosts which I need to use, but this gets overwritten by hosts.tpl when I launch a container from the published image.
I can see that the template exists in the image:
$ tar -tzf images/5ea8871daabdf97c953a76dc07269be56949a39c7953b9b41193ef2f807c1610.incus_combined.tar.gz --exclude rootfs
metadata.yaml
templates
templates/cloud-init-meta-data.tpl
templates/cloud-init-network-config.tpl
templates/cloud-init-user-data.tpl
templates/cloud-init-vendor-data.tpl
templates/hostname.tpl
templates/hosts.tpl
I want to either remove/disable hosts.tpl, or replace it with my own customized one. What’s the best way to do this, whilst leaving the rest of the templates including cloud-init?
If I mangle the tarfile directly to change/remove templates/hosts.tpl and/or change metadata.yaml, won’t this break the image checksum?
incus image show, incus image info and incus image edit don’t show the templates. incus image generate-metadata produces one with templates: {}. Ideally I’d edit hosts.tpl before publishing the image, but I can’t see how.
Do I need to start from scratch with distrobuilder?
Thanks!