Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNM/WIP STUFF #3

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
*.iso
configs/ssh*
group_vars/all
venv/
printer-configs/
environment.cloudcontest.org/
2 changes: 1 addition & 1 deletion build-final.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function waitforssh() {
fi
}

qemu-system-x86_64 -smp 1 -m 1024 -drive file="$IMGFILE",index=0,media=disk,format=raw -global isa-fdc.driveA= --enable-kvm -net user,hostfwd=tcp::$SSHPORT-:22 -net nic --daemonize --pidfile $PIDFILE -vnc :0 -vga qxl -spice port=5901,disable-ticketing -usbdevice tablet
qemu-system-x86_64 -smp 2 -m 4096 -drive file="$IMGFILE",index=0,media=disk,format=raw -global isa-fdc.driveA= --enable-kvm -net user,hostfwd=tcp::$SSHPORT-:22 -net nic --daemonize --pidfile $PIDFILE -vnc :0 -vga qxl -spice port=5901,disable-ticketing -usbdevice tablet

ALIVE=0
waitforssh
Expand Down
31 changes: 31 additions & 0 deletions configs/2204_autoinstall.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,52 @@ autoinstall:
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB9pjASmP4wQkhJ1VEbl0l1Vgn3lsOzctRS2m0wBVlaO ICPC ImageAdmin Key
allow-pw: yes

# failures at removing snap...sigh
# install the minimal version (see casper/install-sources.yaml on the iso)
# This avoids snapd being installed
# source:
# id: ubuntu-server-minimal

# try something else to disable snapd (remove it from the installer?)
# Can't do this, subiquity (the installer) is a snap
# early-commands:
# - apt-get autoremove -y --purge snapd

# Tried to disable snapd from being installed, and while this preference _is_ added properly,
# it doesn't actually work.
# apt:
# preferences:
# - package: snapd
# pin: release *
# pin-priority: -1

packages: []
# updates: all # install all updates after the installer finishes (default 'security')
updates: security # install all updates after the installer finishes (default 'security')
late-commands:
# Fix the filesystem type of the icpc fat32 partition (curtain sets it to "Linux filesystem", even though we specify partition_type)
- sfdisk --part-type /dev/sda 3 EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 # TAG:USB_PARTITION_ENABLED

# This fixes a weird issue with qemu not wanting to boot the system unless you
# hold down shift, and manually pick the os to boot.
# Disable graphical grub console
# - sed -i -e 's/#\(GRUB_TERMINAL.*\)/\1/' /target/etc/default/grub

# Enable passwordless sudo
- echo '%sudo ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/icpc
# TODO: what was the value of GRUB_CMDLINE_LINUX before this line nukes it?
- cp /target/etc/default/grub /target/etc/default/grub.orig
- sed -ie 's/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX="net.ifnames=0"/' /target/etc/default/grub
# Do these matter(or did they get nuked above?)
- sed -ie 's/quiet splash//' /target/etc/default/grub

- curtin in-target update-grub2
# This also fails to remove snapd for some reason or another:
# https://gist.github.com/s3rj1k/55b10cd20f31542046018fcce32f103e?permalink_comment_id=4429378#gistcomment-4429378
# - curtin in-target apt-get -y -q purge snapd

# The original version of subiquity had a bug where specifying --target /target was required
# - curtin in-target --target /target update-grub2

# Poweroff because otherwise it'll reboot
- poweroff
119 changes: 119 additions & 0 deletions configs/2404_autoinstall.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#cloud-config

# Set up ssh/sudo access to the installer environment(so debugging any issues during installation is possible)
users:
- name: default
ssh_authorized_keys:
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB9pjASmP4wQkhJ1VEbl0l1Vgn3lsOzctRS2m0wBVlaO ICPC ImageAdmin Key
- name: imageadmin
sudo: 'ALL=(ALL) NOPASSWD:ALL'
ssh_authorized_keys:
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB9pjASmP4wQkhJ1VEbl0l1Vgn3lsOzctRS2m0wBVlaO ICPC ImageAdmin Key

# Try to add a key elsewhere to enable login...
ssh_authorized_keys:
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB9pjASmP4wQkhJ1VEbl0l1Vgn3lsOzctRS2m0wBVlaO ICPC ImageAdmin Key

# Docs on autoinstall are found here: https://ubuntu.com/server/docs/install/autoinstall-reference
# Additional useful resources:
# https://utcc.utoronto.ca/~cks/space/blog/linux/Ubuntu2004ISOAutoinst - how to bundle autoinstall with the cdrom
# https://utcc.utoronto.ca/~cks/space/blog/linux/Ubuntu2004AutoinstFormat - good example of autoinstall setup
autoinstall:
version: 1
# Locale and keyboard layout
locale: en_US.UTF-8
keyboard:
layout: us
variant: ''
toggle: null
timezone: America/New_York
network:
version: 2
ethernets:
# We disable persistent network interface naming on the kernel command line, so this is always eth0
eth0: {dhcp4: true}
storage:
version: 2
# Disable swap
swap: {size: 0}
config:
# Docs on this section are found here: https://curtin.readthedocs.io/en/latest/topics/storage.html
# This makes 4 partitions
# 1 - bios_grub (space for grub stage2 to live) 1MiB
# 2 - EFI partition
# 3 - ICPC fat32 partition (to make files easy to load after the contest ends without booting the usb drive)
# 4 - linux root partition
- {type: disk, id: disk0, grub_device: true, ptable: gpt, wipe: superblock-recursive}
- {type: partition, device: disk0, number: 1, id: partition-bios, flag: bios_grub, size: 1M}
- {type: partition, device: disk0, number: 2, id: partition-efi, flag: boot, size: 128M}
- {type: partition, device: disk0, number: 3, id: partition-icpc, partition_type: EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, name: icpc, size: 192M} # TAG:USB_PARTITION_ENABLED
- {type: partition, device: disk0, number: 4, id: partition-root, flag: linux, size: -1}
- {type: format, volume: partition-efi, id: format-efi, fstype: fat32, label: EFI}
- {type: format, volume: partition-icpc, id: format-icpc, fstype: fat32, label: ICPC} # TAG:USB_PARTITION_ENABLED
- {type: format, volume: partition-root, id: format-root, fstype: ext4, extra_options: ['-m', '0']}
- {type: mount, device: format-efi, id: mount-efi, path: /boot/efi}
# Set commit=60, to help improve performance
- {type: mount, device: format-root, id: mount-root, path: /, options: 'noatime,nodiratime,errors=remount-ro,commit=60'}
identity:
hostname: icpc
username: imageadmin
# This crypted password corresponds to 'imageadmin'
password: $6$D1vml7SluH/Pfw43$upy5UKqf6iZtLGXRXcAUAqCDMpFMWiZcve9tj16/5l1eD8j5YWoVYCmLvxl6eXrRmSKSngIiH5.NJBNMx.SZg0

# Set up ssh with a public key we'll use to bootstrap the rest of the system
ssh:
install-server: yes
authorized-keys:
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB9pjASmP4wQkhJ1VEbl0l1Vgn3lsOzctRS2m0wBVlaO ICPC ImageAdmin Key
allow-pw: yes

# failures at removing snap...sigh
# install the minimal version (see casper/install-sources.yaml on the iso)
# This avoids snapd being installed
# source:
# id: ubuntu-server-minimal

# try something else to disable snapd (remove it from the installer?)
# Can't do this, subiquity (the installer) is a snap
# early-commands:
# - apt-get autoremove -y --purge snapd

# Tried to disable snapd from being installed, and while this preference _is_ added properly,
# it doesn't actually work.
# apt:
# preferences:
# - package: snapd
# pin: release *
# pin-priority: -1

# Install packages for efi secure boot
packages:
- grub-efi
- grub-efi-amd64-signed
- shim-signed

# updates: all # install all updates after the installer finishes (default 'security')
updates: security # install all updates after the installer finishes (default 'security')
late-commands:
# Fix the filesystem type of the icpc fat32 partition (curtain sets it to "Linux filesystem", even though we specify partition_type)
- sfdisk --part-type /dev/sda 3 EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 # TAG:USB_PARTITION_ENABLED

# Enable passwordless sudo
- echo '%sudo ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/icpc
# TODO: what was the value of GRUB_CMDLINE_LINUX before this line nukes it?
- cp /target/etc/default/grub /target/etc/default/grub.orig
- sed -ie 's/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX="net.ifnames=0"/' /target/etc/default/grub
# Do these matter(or did they get nuked above?)
- sed -ie 's/quiet splash//' /target/etc/default/grub

- curtin in-target update-grub2

# Make sure uefi/secure boot is ready to go
- curtin in-target -- grub-install --no-nvram --uefi-secure-boot --target=x86_64-efi /dev/sda

# This also fails to remove snapd for some reason or another:
# https://gist.github.com/s3rj1k/55b10cd20f31542046018fcce32f103e?permalink_comment_id=4429378#gistcomment-4429378
# - curtin in-target apt-get -y -q purge snapd

# Poweroff because otherwise it'll reboot
- poweroff
1 change: 1 addition & 0 deletions configs/2404_metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hostname: icpc
40 changes: 36 additions & 4 deletions create_baseimg.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/bin/bash

# Settings
ISO64="ubuntu-22.04.3-live-server-amd64.iso"
ISO64="ubuntu-24.04.1-live-server-amd64.iso"
OUT64="unattended-${ISO64}"
IMG64="base-amd64.img"

TMPDIR="tmp"
USERDATA="configs/2204_autoinstall.yaml"
METADATA="configs/2204_metadata"
USERDATA="configs/2404_autoinstall.yaml"
METADATA="configs/2404_metadata"

function usage() {
echo "Usage: create_baseimage.sh [-s size]"
echo ""
echo "-s|--size n Size of the resulting image(default 14700M)"
echo "-s|--size n Size of the resulting image(default 28500M)"
echo "--no-usb Don't create a fat32 partition for easy usb mounting"
exit 1
}
Expand Down Expand Up @@ -79,6 +79,7 @@ function create_unattended_iso() {
sed -i -e "/USB_PARTITION_ENABLED/d" "$CONTENTSDIR/autoinst/user-data"
fi

# TODO: skip all this isolinux stuff, and change boot/grub/grub.cfg instead

# Configure grub to start the autoinstall after 3 seconds
cat <<EOF > "$CONTENTSDIR/boot/grub/grub.cfg"
Expand All @@ -95,7 +96,36 @@ menuentry "Install Ubuntu Server (Unattended)" {
initrd /casper/initrd
}
EOF

# Skip language selection menu
# chmod u+w $CONTENTSDIR/isolinux
# echo "en" > "$CONTENTSDIR/isolinux/lang"

# cat <<EOF > "$CONTENTSDIR/isolinux/txt.cfg"
# default install
# label install
# menu label ^Install Ubuntu Server (Unattended)
# kernel /casper/vmlinuz
# append initrd=/casper/initrd autoinstall ds=nocloud-net;seedfrom=/cdrom/autoinst/ net.ifnames=0 --
# label memtest
# menu label Test ^memory
# kernel /install/mt86plus
# EOF

# cat <<EOF > "$CONTENTSDIR/isolinux/isolinux.cfg"
# # D-I config version 2.0
# path
# include menu.cfg
# default vesamenu.c32
# prompt 0
# # 2.5 seconds
# timeout 25
# ui gfxboot bootlogo
# EOF
# echo "en" > "$CONTENTSDIR/isolinux/lang"

set -x
# mkisofs -r -V "ATTENDLESS_UBUNTU" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -quiet -o $OUTISO $CONTENTSDIR

# Finally pack up an ISO the new way
xorriso -as mkisofs -r \
Expand All @@ -116,6 +146,8 @@ EOF
$CONTENTSDIR
set +x

# exit 1

# cleanup
rm -rf "$CONTENTSDIR"
}
Expand Down
3 changes: 3 additions & 0 deletions files/firstboot.service
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ StandardInput=tty
StandardOutput=tty
ExecStart=/bin/bash -c '/bin/chvt 2; /icpc/scripts/icpc_setup'

# TODO could use type=notify along with calling `systemd-notify --ready` from the script to mark it as complete.
# TODO then systemd will restart it until successful

[Install]
WantedBy=graphical.target
WantedBy=multi-user.target
28 changes: 0 additions & 28 deletions files/management-server/coredns.service.j2

This file was deleted.

Loading