Ubuntu is discontinuing support for the Debian-installer based classic server installer from 20.04 LTS (Focal Fossa) making the way for subiquity server installer. This post shows how the Packer build config vary for both installers.
Ubuntu 20.04 live server has only subiquity support. For debian-installer you can use legacy server version.
Autoinstallation lets you answer all those configuration questions ahead of time with autoinstall config and lets the installation process run without any external interaction. The autoinstall config is provided via cloud-init configuration. Values are taken from the config file if set, else default values are used.
There are multiple ways to provide configuration data for cloud-init. Typically user config is stored in
user-data and cloud specific config in
meta-data file. The list of supported cloud datasources can be found in cloudinit docs. Since packer builds it locally, data source is NoCloud in our case and the config files will served to the installer over http.
Packer config to build a VMWare virtual machine from Ubuntu 20.04 live server ISO
2] http/meta-data: empty file
🔐 How to generate hashed password?
mkpasswd --method=SHA-512 --rounds=4096
🧩 Why to include those late-commands?
Issue 1: Packer SSH timeout due to IP change on instance restart
While building in VMWare, restart after installation causes change in IP address of the instance. This leads packer build to timeout awaiting SSH connection. To fix this issue, we can configure MAC address to be send as identifier in DHCP request.
Since there is no option to set
dhcp-identifier via cloud config, this is appended to
ens33 interface in
Issue 2: Default user sudo with no-password
identity doesn’t provide a way to set sudo
NOPASSWD option. So that is written to
sudoers.d/ubuntu file via
Run the packer build:
$ packer build -force ubuntu-20.04-live-server-packer.json ==> Retrieving ISO ==> Trying iso/ubuntu-20.04.1-live-server-amd64.iso ==> Trying iso/ubuntu-20.04.1-live-server-amd64.iso?checksum=sha256%3A443511f6bf12402c12503733059269a2e10dec602916c0a75263e5d990f6bb93 ==> iso/ubuntu-20.04.1-live-server-amd64.iso?checksum=sha256%3A443511f6bf12402c12503733059269a2e10dec602916c0a75263e5d990f6bb93 => /path/to/packer-ubuntu/iso/ubuntu-20.04.1-live-server-amd64.iso ==> Deleting previous output directory... ==> Creating required virtual machine disks ==> Building and writing VMX file ==> Starting HTTP server on port 8100 ==> Starting virtual machine... ==> Waiting 5s for boot... ==> Connecting to VM via VNC (127.0.0.1:5984) ==> Typing the boot command over VNC... ==> Using ssh communicator to connect: 172.16.255.203 ==> Waiting for SSH to become available... ==> Connected to SSH! ==> Provisioning with shell script: /var/folders/lw/n4rl9vm16t38zzv2x_kl74xc0000gn/T/packer-shell298726450 bin cdrom etc lib lib64 lost+found mnt proc run snap sys usr boot dev home lib32 libx32 media opt root sbin srv tmp var ==> Gracefully halting virtual machine... Waiting for VMware to clean up after itself... ==> Deleting unnecessary VMware files... Deleting: output/live-server/packer-ubuntu-20.04-live-server.plist Deleting: output/live-server/startMenu.plist Deleting: output/live-server/vmware.log ==> Compacting all attached virtual disks... Compacting virtual disk 1 ==> Cleaning VMX prior to finishing up... Detaching ISO from CD-ROM device ide0:0... Disabling VNC server... ==> Skipping export of virtual machine (export is allowed only for ESXi)... Build 'ubuntu-20.04-live-server' finished. ==> Builds finished. The artifacts of successful builds are: --> VM files in directory: output/live-server
⏳ Boot interaction sequence for live server
- Initial empty screen
<any key>to goto advanced welcome page
F6to open Other Options popup + activate boot commandline
ESCto close popup & focus on edit existing boot command
initrd=/casper/initrd quiet ---(with cursor at the end)
- The autoinstall boot command in the following format is entered by Packer via VNC connection and then awaits the installation completion:
initrd=/casper/initrd quiet --- autoinstall ds=nocloud-net;seedfrom=http://<ip>:<port>
debian-installer or just
d-i is a text-based automated installer with little user interaction. It consists of a number of components to perform each installation task. Component asks questions to the user based on the priority set.
Preseeding is a way to set answers to questions asked during the installation process, without having to manually enter the answers while the installation is running. We can create a preseed.cfg file and pass it to the debian-installer. In the default mode, when the answer to a question is not present in a preseed,
d-i stops and asks the user for input.
Installation process is quite slow compared to subiquity.
Packer config to build a VMWare virtual machine from Ubuntu 20.04 legacy server ISO
⏳ Boot interaction sequence for legacy server
ESCto goto advanced welcome page
ESCto get popup alert “You are leaving the graphical boot menu and startinng the text mode interface”
Enterto select OK button
- In the boot text mode interface, the boot command in the following format is entered by Packer via VNC connection and then awaits the installation completion. The installation progress will be visible via graphical interface, incase if any necessary value is not present in preseed, installer stops and waits for the user input to proceed.
/install/vmlinuz initrd=/install/initrd.gz auto-install/enable=true debconf/priority=critical preseed/url=http://<ip>:<port>/preseed.cfg --