#cloud-config
# Ubuntu 24.04 LTS Server — unattended install via subiquity autoinstall.
#
# subiquity reads this from the NoCloud datasource: any volume labeled
# CIDATA containing `user-data` (this file) + `meta-data` is auto-discovered.
#
# Before building the seed ISO:
#  1. Replace `REPLACE-WITH-SHA512-HASH` with a real password hash:
#     mkpasswd -m sha-512    # from the `whois` package on Debian/Ubuntu
#                            # or, with isard installed (works everywhere):
#                            #   python3 -c "from isard import sha512_crypt; print(sha512_crypt('mypw'))"
#  2. Replace the `ssh-ed25519 …` line with your own public key.
#
# Build:
#   isard seed cidata \
#     --user-data examples/seed/ubuntu-24.04-autoinstall/user-data \
#     --meta-data examples/seed/ubuntu-24.04-autoinstall/meta-data \
#     -o /tmp/ubuntu-seed.iso

autoinstall:
  version: 1

  # Locale / keyboard
  locale: en_US.UTF-8
  keyboard:
    layout: us

  # Identity
  identity:
    hostname: ubuntu-template
    realname: "Ubuntu Template User"
    username: ubuntu
    password: "REPLACE-WITH-SHA512-HASH"

  # SSH — disable password auth, install only your key
  ssh:
    install-server: true
    allow-pw: false
    authorized-keys:
      - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIREPLACEWITHYOURPUBLICKEY user@host"

  # Storage: full-disk LVM
  storage:
    layout:
      name: lvm

  # Network: DHCP on the first interface IsardVDI gives us
  network:
    version: 2
    ethernets:
      anyeth:
        match:
          name: "en*"
        dhcp4: true

  # Extra packages on top of the standard server image
  packages:
    - vim
    - htop
    - tmux
    - curl
    - qemu-guest-agent

  # Late commands run inside the installed system at /target before reboot.
  late-commands:
    - "curtin in-target --target=/target -- systemctl enable qemu-guest-agent"
    - "echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/90-ubuntu-template"
    - "chmod 0440 /target/etc/sudoers.d/90-ubuntu-template"

  # Don't pause on the "view config" / "reboot now" screens.
  interactive-sections: []
  shutdown: reboot
