Ubuntu autoinstall

user-data

#cloud-config
autoinstall:
  version: 1
  locale: en_US.UTF-8
  keyboard:
    layout: de
  identity:
    hostname: u2104
    username: root
    password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0" # ubuntu
  ssh:
    install-server: yes
    allow-pw: no
    # authorized-keys:
    #   - "ssh-rsa xxxxxxxxxx foo-key"
  apt:
    geoip: true
  # storage:
  #   layout:
  #     name: lvm
  late-commands:
    - curtin in-target --target=/target -- apt update
    - curtin in-target --target=/target -- apt upgrade -y
    - curtin in-target --target=/target -- apt autoremove -y
    - curtin in-target --target=/target -- ssh-import-id-gh panticz
 
  # proxy: http://squid.internal:3128/
touch meta-data
touch vendor-data
 
# start webserver
python3 -m http.server 3003

VM
https://ubuntu.com/server/docs/install/autoinstall-quickstart

# create
truncate -s 10G image.img && kvm -m 1024 \
  -drive file=image.img,format=raw,cache=none,if=virtio \
  -cdrom ~/Downloads/iso/ubuntu-21.04-live-server-amd64.iso \
  -kernel "/media/pako/Ubuntu-Server 21.04 amd64/casper/vmlinuz" \
  -initrd "/media/pako/Ubuntu-Server 21.04 amd64/casper/initrd" \
  -append 'autoinstall ds=nocloud-net;s=http://_gateway:3003/'
 
# allow access to bridgte
sudo mkdir /etc/qemu
echo "allow lxdbr0" | sudo tee /etc/qemu/bridge.conf
 
# start VM connected to bridge lxdbr0
sudo kvm -m 1024 \
  -drive file=image.img,format=raw,cache=none,if=virtio \
  -device virtio-net-pci,netdev=net0 \
  -netdev bridge,id=net0,br=lxdbr0
 
# get VM IP
nmap -sP 192.168.1.*

Pxelinux

label ubuntu
  menu DEFAULT
  menu label Ubuntu autoinstall
  kernel /boot/ubuntu/vmlinuz
  append initrd=/boot/ubuntu/initrd boot=casper iso-scan/filename=/boot/ubuntu/ubuntu-21.04-live-server-amd64.iso only-ubiquity ip=dhcp root=/dev/ram0 autoinstall ds=nocloud-net;s=http://dl.panticz.de/autoinstall/
 
  # https://releases.ubuntu.com/21.04/ubuntu-21.04-live-server-amd64.iso

Links
https://ubuntu.com/server/docs/install/autoinstall-reference
https://ubuntu.com/server/docs/install/autoinstall-schema
https://cloudinit.readthedocs.io/en/latest/topics/modules.html
https://curtin.readthedocs.io/en/latest/