chef / bento

Packer templates for building minimal Vagrant baseboxes for multiple platforms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vagrant / arm64 / Ubuntu Box?

jamiejackson opened this issue · comments

Describe the Enhancement

Provide an arm64 Ubuntu box for VirtualBox.

Describe the Need

My team's in need of an Ubuntu box for a team member's new arm-based Mac. So far, there aren't any boxes on the repository and bento doesn't have that combination. https://app.vagrantup.com/bento/boxes/ubuntu-22.04

He's running a development build of VirtualBox, by the way.

Other members of the team are holding back on upgrading their old laptops so they're not stuck without the development environment.

Current Alternative

I explored creating my own box with Packer (based on an old and rotting, non-bento GitHub repo) but I failed (it wasn't loading up disks properly). As a stopgap, the new team member is trying to get it working with VMWare but that's not ideal. It has a fee, it's a different enviroment that the rest of us are using, and he's running into problem after problem.

Can We Help You Implement This

I may not have a lot of time to put into this, myself, but if it's a matter of following a simple recipe, we might be able to make something happen.

when clicking on that link for the vagrant boxes you can see there are 2 arm boxes for Parallels and Vmware_desktop which is Vmware Fusion for mac or Vmware Player for linux and windows. Vagrant 2.4.0 is needed and make sure you are setting the vagrant provider to one of those virtualization systems otherwise it defaults to virtualbox.

Otherwise I'm not sure what is the ask here.

Argh, sorry. Every time I wrote Vagrant, I'd meant to type VirtualBox. Will edit...

Virtualbox is only beta for Non Intel Macs and isn't supported. I can't get any boxes to build for it on arm architecture.
image

you are welcome to try packer with this repo. Simply clone this repo, install packer, in terminal navigate to this repo. Run packer init packer_templates > packer build -only virtualbox-iso.vm -var-file=os_pkrvars/ubuntu/ubuntu-22.04-aarch64.pkrvars.hcl ./packer_templates if you want a gui add -var 'headless=false' Instructions can also be found in https://github.com/chef/bento/blob/main/README.md

@Stromweld , thanks for the info. I know that VirtualBox for the new Macs is only in beta at the moment but I understand why Bento wouldn't jump on it yet.

We can give those instructions a shot. Do you remember what issue you ran into when you tried arm builds?

Ah, yes. This is what I'd been getting in my own failed Packer attempts, too.

After hacking the following:

diff --git a/os_pkrvars/ubuntu/ubuntu-22.04-aarch64.pkrvars.hcl b/os_pkrvars/ubuntu/ubuntu-22.04-aarch64.pkrvars.hcl
index 35e3798..e49428e 100644
--- a/os_pkrvars/ubuntu/ubuntu-22.04-aarch64.pkrvars.hcl
+++ b/os_pkrvars/ubuntu/ubuntu-22.04-aarch64.pkrvars.hcl
@@ -1,7 +1,7 @@
 os_name                 = "ubuntu"
 os_version              = "22.04"
 os_arch                 = "aarch64"
-iso_url                 = "https://cdimage.ubuntu.com/releases/jammy/release/ubuntu-22.04.3-live-server-arm64.iso"
+iso_url                 = "https://cdimage.ubuntu.com/releases/jammy/release/ubuntu-22.04.4-live-server-arm64.iso"
 iso_checksum            = "file:https://cdimage.ubuntu.com/releases/jammy/release/SHA256SUMS"
 parallels_guest_os_type = "ubuntu"
:

Then running:

packer init packer_templates
packer build -only virtualbox-iso.vm -var-file=os_pkrvars/ubuntu/ubuntu-22.04-aarch64.pkrvars.hcl ./packer_templates

I got this in the guest:

Could not read from the boot medium!
Please insert a bootable medium and reboot.

that's part of the issues troubleshooting so many images, times virtualization providers, times cpu architectures. So many to go through and fix. Typically you have to find the difference in a running config for virtualbox and the config we are generating and then we may have to update the code to make it work. Some arm boxes require EFI others have patches for specific providers and only support those with arm platforms(oracle8 patches form vmware arm but rhel 8 doesn't). Most often it's configuration in the boot_wait and boot_command that needs updating and packer gets stuck at waiting for ssh.

I'd try manually downloading the machine and spinning it up in virtualbox then running vboxmanage command to dump it's config. Then run packer and add -on-error=ask flag to pause before cleaning up and dump the configuration of the packer virtualbox machine and compare to see what is potentially needed to be changed.

Since my last post, I've been trying the ISO directly in virtualbox and there's a problem even there. I'm about to post to the virtualbox mailing list.

I think I'm finding that despite the existence of a VirtualBox beta/test version for the new Macs, there is no useful version in existence.

I have a forum post here to clarify the matter.

that's been my experience so far for virtualbox on arm64.

I haven't given up quite yet, because of a reponse on the forum.

On my Intel Mac, I have just installed a dev snapshot of VirtualBox and I'm trying to build an arm box on it.

This VirtualBox version's VBoxManage createvm seems to expect an architecture flag:

VBoxManage: error: Parameter --platform-architecture is required

I can't figure out how to influence the arguments that Packer/bento sends to VBoxManage, though. I'm not finding it in the bento source. (Maybe this is upstream in Packer?)

Please let me know if you have ideas on how to make progress.

Full command and output:

 % packer build -only virtualbox-iso.vm -var-file=os_pkrvars/ubuntu/ubuntu-22.04-aarch64.pkrvars.hcl ./packer_templates

virtualbox-iso.vm: output will be in this color.

==> virtualbox-iso.vm: Retrieving Guest additions
==> virtualbox-iso.vm: Trying /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
==> virtualbox-iso.vm: Trying /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
==> virtualbox-iso.vm: /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso => /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso
==> virtualbox-iso.vm: Retrieving ISO
==> virtualbox-iso.vm: Trying https://cdimage.ubuntu.com/releases/jammy/release/ubuntu-22.04.4-live-server-arm64.iso
==> virtualbox-iso.vm: Trying https://cdimage.ubuntu.com/releases/jammy/release/ubuntu-22.04.4-live-server-arm64.iso?checksum=sha256%3A74b8a9f71288ae0ac79075c2793a0284ef9b9729a3dcf41b693d95d724622b65
==> virtualbox-iso.vm: https://cdimage.ubuntu.com/releases/jammy/release/ubuntu-22.04.4-live-server-arm64.iso?checksum=sha256%3A74b8a9f71288ae0ac79075c2793a0284ef9b9729a3dcf41b693d95d724622b65 => /Users/jjackson/.cache/packer/a2bcf685fcca57f42a01f519e9e768cc87ac72b2.iso
==> virtualbox-iso.vm: Starting HTTP server on port 8423
==> virtualbox-iso.vm: Creating virtual machine...
==> virtualbox-iso.vm: Error creating VM: VBoxManage error: Oracle VM VirtualBox Command Line Management Interface Version 7.0.97
==> virtualbox-iso.vm: Copyright (C) 2005-2024 Oracle and/or its affiliates
==> virtualbox-iso.vm: 
==> virtualbox-iso.vm: VBoxManage: error: Parameter --platform-architecture is required
==> virtualbox-iso.vm: 
==> virtualbox-iso.vm: Usage - Create a new virtual machine:
==> virtualbox-iso.vm: 
==> virtualbox-iso.vm:   VBoxManage createvm <--name=name> <--platform-architecture= x86 | arm>
==> virtualbox-iso.vm:       [--basefolder=basefolder] [--default] [--group=group-ID [,...]]
==> virtualbox-iso.vm:       [--ostype=ostype] [--register] [--uuid=uuid] [--cipher=cipher]
==> virtualbox-iso.vm:       [--password-id=password-id] [--password=file]
==> virtualbox-iso.vm: Deleting output directory...
Build 'virtualbox-iso.vm' errored after 6 seconds 812 milliseconds: Error creating VM: VBoxManage error: Oracle VM VirtualBox Command Line Management Interface Version 7.0.97
Copyright (C) 2005-2024 Oracle and/or its affiliates

VBoxManage: error: Parameter --platform-architecture is required

Usage - Create a new virtual machine:

  VBoxManage createvm <--name=name> <--platform-architecture= x86 | arm>
      [--basefolder=basefolder] [--default] [--group=group-ID [,...]]
      [--ostype=ostype] [--register] [--uuid=uuid] [--cipher=cipher]
      [--password-id=password-id] [--password=file]

==> Wait completed after 6 seconds 812 milliseconds

==> Some builds didn't complete successfully and had errors:
--> virtualbox-iso.vm: Error creating VM: VBoxManage error: Oracle VM VirtualBox Command Line Management Interface Version 7.0.97
Copyright (C) 2005-2024 Oracle and/or its affiliates

VBoxManage: error: Parameter --platform-architecture is required

Usage - Create a new virtual machine:

  VBoxManage createvm <--name=name> <--platform-architecture= x86 | arm>
      [--basefolder=basefolder] [--default] [--group=group-ID [,...]]
      [--ostype=ostype] [--register] [--uuid=uuid] [--cipher=cipher]
      [--password-id=password-id] [--password=file]

==> Builds finished but no artifacts were created.

Actually, I forgot to try the arm ISO directly in the dev snapshot VirtualBox until now. It's still failing, so I'll go back to the forum with this issue.

https://github.com/chef/bento/blob/main/packer_templates/pkr-variables.pkr.hcl#L169 this is the variable you'd want to add to os_pkrvars/ubuntu/ubuntu-22.04-aarch64.pkrvars.hcl file. You'd want to copy the existing default value and then add the flag for architecture.

if that works than it'd be a quick fix for me to be able to add a local variable that would be default add that architecture flag based on the template arch.