#cloud-config
autoinstall:
  version: 1
  source:
    id: ubuntu-desktop-minimal
  identity:
    hostname: autoinstall
    password: $y$j9T$MYuc23vJIEA6BBnpY1y001$0FMBxaFV/5xumNOTq9o.AG68KRe9wVYhvVoSUsi75L2
    username: autoinstall
  locale: en_US.UTF-8
  keyboard:
    layout: de
    variant: nodeadkeys
  storage:
    layout:
      name: lvm
      sizing-policy: scaled
      password: start123
      match:
        size: largest  
  timezone: Europe/Berlin
  packages:
    - gcc
    - make
    - unrar
    - ansible
    - sshpass
    - git
    - flatpak
    - gnome-software-plugin-flatpak
    - bzip2
    - ubuntu-restricted-extras
    - exfatprogs
    - 7zip
    - gnome-snapshot
  ssh:
    install-server: true
    allow-pw: true
  late-commands:
    - lvcreate -L $(($(cat /proc/meminfo | grep MemTotal | awk -F\  '{ print $2 }')/1024/1024+1))g -n swap-lv /dev/ubuntu-vg
    - mkswap /dev/ubuntu-vg/swap-lv
    - sed -i "s/swap.img/dev\/ubuntu-vg\/swap-lv/" /target/etc/fstab
    - rm /target/swap.img
    - lvresize -r -l +90%FREE /dev/ubuntu-vg/ubuntu-lv
    - curtin in-target -- flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
    - lspci | grep -q BCM43; if [ $? = 0 ]; then curtin in-target -- apt -y install broadcom-sta-dkms; fi
    - lspci | grep -q VGA.*NVIDIA; if [ $? = 0 ]; then curtin in-target -- ubuntu-drivers install; fi

