Score:0

Workaround wanted for mirror connection failure during autoinstall

cn flag

We are using Packer 1.7.10 under VirtualBox 6.1.30 on macOS 11.6.3 to build development VMs based on Ubuntu Server 20.04.3, using cloud-init autoinstall from the server ISO. The user-data file includes a long list of packages to install during the first boot.

When it works, it works well. But frequently installing those packages will fail, 15 or 20 minutes into the build. What is visible of the installer output in the VirtualBox console screen shows that some of the package installations have completed. Autoinstall prompts for user input, and Packer is unable to detect that the installation has failed.

We observed similar failures under our previous VM build scripts, using preseed files with Ubuntu 18.04, and it was usually because an Ubuntu mirror dropped or refused a connection. The workaround was to specify a different mirror in the preseed file and try again.

Is there any way to tell autoinstall to retry installing packages, or choose a different mirror, when the connection to the mirror is lost? Or would we be better off doing it in a shell script as a Packer provisioner?

The user-data file, with some details fudged:

#cloud-config
autoinstall:
  version: 1
  # The build will fail with an SSH authentication error if this is omitted.
  identity:
    hostname: "dev-gui"
    username: "dsa"
    realname: "Dis Simple App"
    password: OMITTED
  locale: "en_US.UTF-8"
  keyboard:
    layout: "en"
    variant: ""
  refresh-installer:
    update: yes
  ssh:
    install-server: true
    allow-pw: true
  # We do NOT want Packer to start running provisioners until this
  # VM has rebooted.
  early-commands:
    - "systemctl stop sshd"
  apt:
    preserve_sources_list: false
    geoip: true
  user-data:
    # Set a sane timezone
    timezone: America/Los_Angeles
    # User and group info
    groups:
      - docker
      - dsa
      - postgres
      - vboxsf
    users:
      - name: "dsa"
        gecos: "Dis Simple App"
        primary_group: "dsa"
        groups: [adm docker dsa postgres sudo vboxsf]
        passwd: OMITTED
        lock_passwd: false
        sudo: "ALL=(ALL) NOPASSWD:ALL"
  # Packages to install
  packages:
    - ant
    - automake
    - batctl
    - bison
    - bmon
    - bridge-utils
    - ccache
    - chrpath
    - clang-tidy
    - cmake
    - cppcheck
    - curl
    - debconf-utils
    - diffstat
    - dkms
    - docker.io
    - doxygen
    - emacs-nox
    - expect
    - flex
    - g++-multilib
    - gnuplot-nox
    - iproute2
    - lcov
    - libcap-ng-dev
    - libglib2.0-dev
    - libncurses-dev
    - libpixman-1-dev
    - libtool
    - libtinyxml2-dev
    - module-assistant
    - nfs-kernel-server
    - nux-tools
    - openjdk-11-jdk
    - pylint
    - python3-git
    - python3-pip
    - python3-pygments
    - python3-venv
    - python3-virtualenv
    - python3.8-dev
    - socat
    - subversion
    - texinfo
    - traceroute
    - u-boot-tools
    - unzip
    - xvfb
  snaps:
    - name: node
      channel: "16/stable"
      classic: true
    - name: codechecker
      classic: true
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.