Ubuntu Server 20.04 在自动“打包程序”自动安装过程中无法安装退出状态为 100 的软件包

Ubuntu Server 20.04 在自动“打包程序”自动安装过程中无法安装退出状态为 100 的软件包

我正在尝试自动安装 Ubuntu Server 20.04(详情见下文)以packer创建 Vagrant 框。但我在安装时卡住了build-essential,shell 以状态 100 退出。回溯是 在这张照片中

看来我没有网络共。

我使用的配置是 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

如果需要更多信息,请告诉我。我很感激任何帮助。

答案1

好吧,进一步挖掘就会找到答案。

我必须将网络适配器从 更改ens192enp0s3,这显然是虚拟机正在使用的适配器。

我在安装过程中发现它使用ip addr showSSH 终端连接到虚拟机。我仍然不确定这是否是正确的方法,因为我的大多数谷歌搜索都显示人们正在使用ens192并且显然对他们有用。欢迎任何意见。

相关内容