Skip to content

Commit 1ab87a7

Browse files
committed
Add beta ubuntu server 26.04 autoinstall
1 parent c462321 commit 1ab87a7

7 files changed

Lines changed: 233 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Ubuntu Server 26.04 autoinstall
2+
3+
## Preparing the ISO
4+
5+
```
6+
$ curl -LO \
7+
https://releases.ubuntu.com/26.04/ubuntu-26.04-beta-live-server-amd64.iso
8+
9+
docker pull docker.io/boxcutter/ubuntu-autoinstall
10+
UBUNTU_SERVER_26_04_ISO=ubuntu-26.04-beta-live-server-amd64.iso
11+
docker run -it --rm \
12+
--mount type=bind,source="$(pwd)",target=/data \
13+
docker.io/boxcutter/ubuntu-autoinstall \
14+
--autoinstall autoinstall.yaml \
15+
--grub grub.cfg \
16+
--config-root \
17+
--source ${UBUNTU_SERVER_26_04_ISO} \
18+
--destination ${UBUNTU_SERVER_26_04_ISO}-autoinstall.iso
19+
20+
# Verify that the autoinstall is located in root
21+
$ isoinfo -R -i \
22+
${UBUNTU_SERVER_26_04_ISO}-autoinstall.iso -f | grep -i autoinstall
23+
/autoinstall.yaml
24+
```
25+
26+
## Testing the autoinstall in a VM
27+
28+
```
29+
UBUNTU_SERVER_26_04_ISO=ubuntu-26.04-beta-live-server-amd64.iso
30+
UBUNTU_SERVER_26_04_AUTOINSTALL_ISO=${UBUNTU_SERVER_26_04_ISO}-autoinstall.iso
31+
sudo cp ${UBUNTU_SERVER_26_04_AUTOINSTALL_ISO} \
32+
/var/lib/libvirt/iso/${UBUNTU_SERVER_26_04_AUTOINSTALL_ISO}
33+
34+
virt-install \
35+
--connect qemu:///system \
36+
--name ubuntu-server-2604 \
37+
--boot uefi \
38+
--cdrom /var/lib/libvirt/iso/${UBUNTU_SERVER_26_04_AUTOINSTALL_ISO} \
39+
--disk pool=default,format=qcow2,bus=virtio,size=60 \
40+
--memory 3192 \
41+
--vcpus 2 \
42+
--os-variant ubuntu24.04 \
43+
--network network=host-network,model=virtio \
44+
--graphics none \
45+
--noautoconsole \
46+
--console pty,target_type=serial \
47+
--debug
48+
49+
# To view install. Once it completes it will stop the vm:
50+
$ virsh console ubuntu-server-2604
51+
$ virt-viewer ubuntu-server-2604
52+
53+
# Start the VM again to verify everything looks good
54+
$ virsh start ubuntu-server-2604
55+
$ virsh console ubuntu-server-2604
56+
```
57+
58+
```
59+
virsh snapshot-create-as \
60+
--domain ubuntu-server-2604 \
61+
--name clean \
62+
--description "Initial install"
63+
64+
virsh snapshot-list ubuntu-server-2604
65+
virsh snapshot-revert ubuntu-server-2604
66+
virsh snapshot-delete ubuntu-server-2604
67+
68+
virsh shutdown ubuntu-server-2604
69+
virsh shutdown ubuntu-server-2604
70+
```
71+
```
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#cloud-config
2+
autoinstall:
3+
version: 1
4+
network:
5+
version: 2
6+
ethernets:
7+
enp1s0:
8+
dhcp4: false
9+
dhcp6: false
10+
optional: true
11+
bridges:
12+
br0:
13+
interfaces: [enp1s0]
14+
dhcp4: true
15+
dhcp6: false
16+
accept-ra: false
17+
link-local: []
18+
storage:
19+
layout:
20+
name: lvm
21+
sizing-policy: all
22+
timezone: UTC
23+
keyboard:
24+
layout: us
25+
apt:
26+
preserve_sources_list: false
27+
mirror-selection:
28+
primary:
29+
# http://archive.ubuntu.com/ubntu
30+
- uri: "https://crake-nexus.org.boxcutter.net/repository/ubuntu-archive-apt-proxy/ubuntu"
31+
arches: [i386, amd64]
32+
# http://ports.ubuntu.com/ubuntu-ports
33+
- uri: "https://crake-nexus.org.boxcutter.net/repository/ubuntu-ports-proxy/ubuntu-ports"
34+
arches: [s390x, arm64, armhf, powerpc, ppc64el, riscv64]
35+
packages:
36+
- qemu-guest-agent
37+
ssh:
38+
install-server: yes
39+
allow-pw: yes
40+
late-commands:
41+
# Because we're using preserve_hostname to allow manual setting of the
42+
# hostname, set an initial hostname manually - the identity block requires
43+
# a username and it doesn't support flexible enough configuration
44+
# NOTE: 'curtin in-target' doesn't invoke a shell, so you need to run
45+
# commands within a shell that need redirection.
46+
- curtin in-target -- sh -c 'echo generic-server > /etc/hostname'
47+
# Configure grub to use serial console for display
48+
- curtin in-target -- sed -ie 's/GRUB_TIMEOUT=.*/GRUB_TIMEOUT=30/' /etc/default/grub
49+
- curtin in-target -- sed -ie 's/GRUB_TIMEOUT_STYLE=.*/GRUB_TIMEOUT=countdown/' /etc/default/grub
50+
- curtin in-target -- sed -ie 's/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX="console=tty1 console=ttyS0,115200n8 systemd.wants=serial-getty@ttyS0"/' /etc/default/grub
51+
- curtin in-target -- sed -ie 's/#GRUB_TERMINAL=.*/GRUB_TERMINAL="console serial"/' /etc/default/grub
52+
- curtin in-target -- update-grub
53+
user-data: # cloud-init starts here
54+
preserve_hostname: true
55+
users:
56+
# Temporary user for bootstrapping
57+
- name: autobot
58+
uid: 63112
59+
primary_group: users
60+
groups: users
61+
shell: /bin/bash
62+
# Testing with a plaintext password
63+
plain_text_passwd: superseekret
64+
# Replace with your generated salted SHA-512 hash w/ 'openssl passwd -6'
65+
# passwd: "$6$W32sh2s3EDp01Jvnif.hT2MB.dZ9mSx6txdPiz..."
66+
sudo: ALL=(ALL) NOPASSWD:ALL
67+
lock_passwd: false
68+
ssh_authorized_keys:
69+
# taylor
70+
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEWerEkujoB7ipGnWJwnPGFu3DuUQJtc1zB6YqjGRziE sheila
71+
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINRK4hkcpUiaSkiLEytgwMYcKylBioXPLx1TnwJFrLPl mahowald
72+
chpasswd:
73+
expire: false
74+
ssh_pwauth: true
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
set -x
4+
5+
UBUNTU_SERVER_26_04_ISO=ubuntu-26.04-beta-live-server-amd64.iso
6+
UBUNTU_SERVER_26_04_AUTOINSTALL_ISO="${UBUNTU_SERVER_26_04_ISO}-autoinstall.iso"
7+
8+
sudo rm "${UBUNTU_SERVER_26_04_AUTOINSTALL_ISO}"
9+
10+
docker pull docker.io/boxcutter/ubuntu-autoinstall
11+
docker run -it --rm \
12+
--mount type=bind,source="$(pwd)",target=/data \
13+
docker.io/boxcutter/ubuntu-autoinstall \
14+
--autoinstall autoinstall.yaml \
15+
--grub grub.cfg \
16+
--config-root \
17+
--source ${UBUNTU_SERVER_26_04_ISO} \
18+
--destination ${UBUNTU_SERVER_26_04_AUTOINSTALL_ISO}
19+
20+
sudo rm "/var/lib/libvirt/iso/${UBUNTU_SERVER_26_04_AUTOINSTALL_ISO}"
21+
sudo cp ${UBUNTU_SERVER_26_04_AUTOINSTALL_ISO} \
22+
/var/lib/libvirt/iso/${UBUNTU_SERVER_26_04_AUTOINSTALL_ISO}
23+
24+
virt-install \
25+
--connect qemu:///system \
26+
--name ubuntu-server-2604 \
27+
--boot uefi \
28+
--cdrom /var/lib/libvirt/iso/${UBUNTU_SERVER_26_04_AUTOINSTALL_ISO} \
29+
--disk pool=default,format=qcow2,bus=virtio,size=60 \
30+
--memory 3192 \
31+
--vcpus 2 \
32+
--os-variant ubuntu24.04 \
33+
--network network=host-network,model=virtio \
34+
--graphics none \
35+
--noautoconsole \
36+
--console pty,target_type=serial \
37+
--debug
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
virsh destroy ubuntu-server-2604
2+
virsh undefine ubuntu-server-2604 --nvram --remove-all-storage
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
set timeout=30
2+
3+
serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1
4+
terminal_input console serial
5+
terminal_output console serial
6+
7+
menuentry "Ubuntu Server Autoinstall" {
8+
set gfxpayload=text
9+
linux /casper/vmlinuz console=tty1 console=ttyS0,115200n8 systemd.wants=serial-getty@ttyS0 autoinstall ---
10+
initrd /casper/initrd
11+
}
12+
menuentry "Ubuntu Server with the HWE kernel" {
13+
set gfxpayload=text
14+
linux /casper/hwe-vmlinuz autoinstall ds=nocloud\;s=/cdrom/nocloud/ ---
15+
initrd /casper/hwe-initrd
16+
}
17+
grub_platform
18+
if [ "$grub_platform" = "efi" ]; then
19+
menuentry 'Boot from next volume' {
20+
exit 1
21+
}
22+
menuentry 'UEFI Firmware Settings' {
23+
fwsetup
24+
}
25+
else
26+
menuentry 'Test memory' {
27+
linux16 /boot/memtest86+.bin
28+
}
29+
fi
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ip=$(virsh domifaddr ubuntu-server-2604 --source agent \
2+
| awk '$1!="lo" && /ipv4/ {print $4; exit}' \
3+
| cut -d'/' -f1
4+
)
5+
6+
docker container run -t --rm \
7+
--mount type=bind,source="$(pwd)/test",target=/share \
8+
--env ip \
9+
docker.io/boxcutter/cinc-auditor exec . \
10+
--no-distinct-exit \
11+
--no-create-lockfile \
12+
--password superseekret \
13+
--target "ssh://autobot@${ip}"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
describe command('hostname') do
2+
its('stdout.strip') { should cmp 'generic-server' }
3+
end
4+
5+
describe file('/etc/hostname') do
6+
its('content.strip') { should cmp 'generic-server' }
7+
end

0 commit comments

Comments
 (0)