Comment 2 for bug 1960278

Revision history for this message
Vern Hart (vern) wrote :

I started with a live iso provided by the customer called vyos-equuleus-20200220z-amd64.iso. Here are my notes for converting this to a maas deployable image:

  # mount the iso
  mkdir /tmp/vyos
  sudo mount -o loop vyos-equuleus-20200220z-amd64.iso /tmp/vyos
  # extract the squashfs
  sudo unsquashfs -d /tmp/vyos-root /tmp/vyos/live/filesystem.squashfs
  # enter vyos-root
  sudo LC_ALL=C chroot /tmp/vyos-root
  # install required packages and enable fastboot
  apt update
  apt install cloud-init -y
  sed -i 's/^\(GRUB_CMDLINE_LINUX="\?\)/\1fastboot /' /etc/default/grub
  # start ssh
  cat <<EOF> /etc/cloud/cloud.cfg.d/99-ssh.cfg
  runcmd:
    - systemctl enable ssh
    - systemctl start ssh
  EOF
  # make sure the interfaces.d directory is supported
  grep ^source /etc/network/interfaces ||
    echo "source /etc/network/interfaces.d/*" >> /etc/network/interfaces
  # create a tar
  cd /tmp/vyos-root/
  sudo tar -C /tmp/vyos-root -czf ~/vyos-equuleus-20200220z-maas-amd64.tgz *
  sudo chown ubuntu.ubuntu ~/vyos-equuleus-20200220z-maas-amd64.tgz
  cd -
  # upload to maas
  maas root boot-resources create name=custom/vyos-equuleus title="Vyos Equuleus 20200220z" architecture=amd64/generic content@=$HOME/vyos-equuleus-20200220z-maas-amd64.tgz

The resulting 378M image is here: https://drive.google.com/file/d/1yjXrvkUHIlkN8_Rv3PT_6KbiaHe6VcyK/view

After adding a curtin_userdata_custom file I was able to boot the image on a kvm machine (though ssh keys are not properly installed -- default user pw is vyos vyos). The last of my notes:

# create the following file in /var/snap/maas/current/preseeds/curtin_userdata_custom
# and copy it to all three maas servers
# (including the cloud-config line that looks like a comment)

#cloud-config
kernel:
  fallback-package: linux-image-5.4.99-amd64-vyos
  package: linux-image-5.4.99-amd64-vyos
  # default debian buster kernel is 4.19.0
  #fallback-package: linux-image-amd64
  #package: linux-image-amd64

apt:
  preserve_sources_list: false
  sources_list: | # written by curtin custom preseed
    deb http://deb.debian.org/debian buster main contrib non-free
    deb-src http://deb.debian.org/debian buster main contrib non-free
    deb http://deb.debian.org/debian-security buster/updates main contrib non-free
    deb-src http://deb.debian.org/debian-security buster/updates main contrib non-free
    deb http://deb.debian.org/debian buster-updates main contrib non-free
    deb-src http://deb.debian.org/debian buster-updates main contrib non-free
    deb http://deb.debian.org/debian buster-backports main contrib non-free
    deb-src http://deb.debian.org/debian buster-backports main contrib non-free

early_commands:
  000_update_repositories: apt update
  010_install_apt_https: apt install -y apt-transport-https ca-certificates efibootmgr xfsprogs

debconf_selections:
 maas: |
  {{for line in str(curtin_preseed).splitlines()}}
  {{line}}
  {{endfor}}

late_commands:
  maas: [wget, '--no-proxy', '{{node_disable_pxe_url}}', '--post-data', '{{node_disable_pxe_data}}', '-O', '/dev/null']
  00_target: mount --bind $TARGET_MOUNT_POINT /mnt
  90_datasource: host=$(grep metadata_url /etc/cloud/cloud.cfg.d/91_kernel_cmdline_url.cfg | sed 's/^.*\/\///;s/:.*//'); ip=$(dig +short $host | head -1); awk '/^[^ ]/&&(flag){flag=0}/^datasource:/{flag=1}flag' /etc/cloud/cloud.cfg.d/91_kernel_cmdline_url.cfg | sed "s/curtin//; s/\/\/[^:]*:/\/\/$ip:/;" > /mnt/etc/cloud/cloud.cfg.d/99-datasource.cfg