5

I've read the entire autoinstall documentation and the entire cloud-init documentation, but I still don't understand the apparent overlap/redundancy between the ability to install packages in autoinstall, vs the ability to install packages via the user-data section.

What I want is to install packages and bake them into my image. I don't want to have to wait for packages to install when I clone the image.

This post isn't specific to installing packages, but it opened my eyes to the fact that there's an "installation environment" and an "installed environment" (or is "target" the better term?). I think it would help if I understood how this works.

Also related, I think, does "first boot" happen during the autoinstall procedure, or does "first boot" happen when I clone the image?

There are other redundancies between autoinstall and user-data... But I think it will help if I can better understand the things above.

For the record, I'm using packer to create templates in Proxmox.

1 Answers1

9

If you use an autoinstall configuration like this

#cloud-config
autoinstall:
  packages:
  - cowsay
  user-data:
    packages:
    - rolldice

The package cowsay will be installed during the installation. The package rolldice will be installed by cloud-init during first boot.

If the package goal is to "bake" the packages into the image then the method for cowsay should be used.

Anything in the user-data section gets used by cloud-init. You can see it get put into /etc/cloud/cloud.cfg.d/99-installer.cfg on the installed system.

notes

  • I also avoid using the user-data method because cloud-init will attempt to install or upgrade the package(s) during every boot.
  • There is no significance to the packages in the example. They are just tiny, simple, and easy to test with.
  • I tested using Ubuntu 22.04 (subiquity 22.04.2).