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.
subiquity
subiquity is the Ubuntu server’s new automated installer, which was introduced in 18.04
. It is the server counterpart of ubiquity installer used by desktop live CD installation.
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
1] ubuntu-20.04-live-server-packer.json:
|
|
2] http/meta-data: empty file
3] http/user-data:
|
|
Notes
🔐 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.
dhcp-identifier: mac
Since there is no option to set dhcp-identifier
via cloud config, this is appended to ens33
interface in /etc/netplan/00-installer-config.yaml
via late-commands
.
Issue 2: Default user sudo with no-password
Cloud config identity
doesn’t provide a way to set sudo NOPASSWD
option. So that is written to sudoers.d/ubuntu
file via late-commands
.
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
- Press
<any key>
to goto advanced welcome page - Press
F6
to open Other Options popup + activate boot commandline - Press
ESC
to close popup & focus on edit existing boot commandinitrd=/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
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
1] ubuntu-20.04-legacy-server-packer.json:
|
|
2] http/preseed.cfg:
|
|
⏳ Boot interaction sequence for legacy server
- Press
ESC
to goto advanced welcome page - Press
ESC
to get popup alert “You are leaving the graphical boot menu and startinng the text mode interface” - Press
Enter
to 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 --
Related Links
- Automated server install config referece
- Cloud-init documentation
- Netplan reference
- Packer VMware Builder (from ISO)
- Packer Unattended Installation for Debian
- Difference between live and alternative
- How the debian-installer works
- Using preseeding
- Preseed file example
Code examples repo: |