Score:0

Ubuntu Server 20.04 can't install packages with exit status 100 during automated `packer` autoinstall

be flag

I'm trying to autoinstall Ubuntu Server 20.04 (details below) with packer to create a Vagrant box. But I am getting stuck at installing build-essential, the shell exiting with status 100. The traceback is in the this picture.

It seems I don't have internet altogether.

The configuration I am using is: ubuntu2004.pkr.hcl:

source "virtualbox-iso" "autogenerated_1" {
  boot_command            = ["<enter><wait2><enter><wait><f6><esc><wait>", "autoinstall<wait2> ds=nocloud;", "<wait><enter>"]
  boot_wait               = "2s"
  cd_files                = ["./http/user-data", "./http/meta-data"]
  cd_label                = "cidata"
  disk_size               = 8192
  guest_additions_path    = "VBoxGuestAdditions_{{ .Version }}.iso"
  guest_os_type           = "Ubuntu_64"
  headless                = false
  http_directory          = "http"
  iso_checksum            = "sha256:f8e3086f3cea0fb3fefb29937ab5ed9d19e767079633960ccb50e76153effc98"
  iso_urls                = ["https://releases.ubuntu.com/focal/ubuntu-20.04.3-live-server-amd64.iso"]
  shutdown_command        = "echo 'ubuntu'|sudo -S shutdown -P now"
  ssh_handshake_attempts  = "20"
  ssh_password            = "ubuntu"
  ssh_port                = 22
  ssh_username            = "ubuntu"
  ssh_wait_timeout        = "10000s"
  vboxmanage              = [["modifyvm", "{{ .Name }}", "--memory", "1024"], ["modifyvm", "{{ .Name }}", "--cpus", "1"]]
  virtualbox_version_file = ".vbox_version"
  vm_name                 = "packer-ubuntu-20.04-amd64"
}

build {
  sources = ["source.virtualbox-iso.autogenerated_1"]

  provisioner "shell" {
    scripts = ["scripts/init.sh", "scripts/cleanup.sh"]
  }

  post-processor "vagrant" {
    compression_level = "8"
    output            = "ubuntu-20.04-<no value>.box"
  }
}

user-data:

#cloud-config
autoinstall:
  version: 1
  locale: en_US
  keyboard:
    layout: en
    variant: us
  network:
    network:
      version: 2
      ethernets:
        ens192:
          dhcp4: true
  storage:
    layout:
      name: lvm
  identity:
    hostname: ubuntu-server
    username: ubuntu
    password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0"
  ssh:
    install-server: yes
    allow-pw: true
    authorized-keys:
      - ssh-ed25519 <<an-ssh-public-key-I-generated-on-my-desktop-with-ssh-keygen>>
  user-data:
    disable_root: false
  packages:
    - openssh-server
    - build-essential
  late-commands:
    - echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/ubuntu

Let me know if more information is needed. I appreciate any help.

Score:0
be flag

All right, some more digging showed the answer.

I had to change the network adapter from ens192 to enp0s3, which was apparently the adapter the VM was using.

I found it using ip addr show from a SSH terminal to the VM during the installation. I'm still not sure if this is the correct way to do it, since most of my googling showed that people are using ens192 and apparently works for them. Any opinions are welcome.

cindrmon avatar
cn flag
@AndrewLowther my configuration never had any network directive at all and I still get this issue. i don't know what I'm doing wrong.
Andrew Lowther avatar
jp flag
The simplest thing is to remove the `network:` configuration completely. The default configuration will be used and works for simple setups. https://askubuntu.com/a/1329971/376778
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.