Logic of templating Ubuntu 20.04 without preseed configuration files

Hi,

I am not exactly sure how I am supposed to use Packer with Ubuntu 20.04 if Canonical has given d-i (debian-installer/preseeding) up, so I’m trying to form a perspective on how to basically use Packer and then apply Terraform on that template.

So the question is simple: if Ubuntu 20.04 is supposed to work with cloud-init from the very beginning (which you can use by adding the information in the kernel command line: autoinstall ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/), then how am I supposed to apply any configuration dynamically afterwards? The server needs to recreate its ssh-keys, I need to reconfigure the network for each new virtual machine and so on. But if cloud-init runs only once, how are you supposed to run it again? What would be a standard way of going around this problem?

The same premise can be found here, in the hashicorps’ documentation: https://registry.terraform.io/providers/Telmate/proxmox/latest/docs/guides/cloud_init

You would customise the template to however you wished with packer and then at the end you would generalise the image, removing naming, ip config etc / reset cloud-init (rm -rf /var/lib/cloud/instances), deleting its config etc, so it runs again.

Also to reset cloud-init (probably better)

sudo cloud-init clean

This will make it re-run on the next boot, resetting the ip, ssh keys etc.