Skip to content

Conversation

rubisher
Copy link

@rubisher rubisher commented May 4, 2025

This job still need to be improved but at least a simple rough test test works:

└─$ packer build -on-error=ask -only=virtualbox-iso.vm -var-file=./os_pkrvars/alpine/alpine-3.21-x86_64.pkrvars.hcl  ./packer_templates
virtualbox-iso.vm: output will be in this color.
[...]
==> virtualbox-iso.vm (vagrant): Creating Vagrant box for 'virtualbox' provider
    virtualbox-iso.vm (vagrant): Copying from artifact: builds/build_files/packer-alpine-3.21-x86_64-virtualbox/alpine-3.21-amd64-disk001.vmdk
    virtualbox-iso.vm (vagrant): Copying from artifact: builds/build_files/packer-alpine-3.21-x86_64-virtualbox/alpine-3.21-amd64.ovf
    virtualbox-iso.vm (vagrant): Renaming the OVF to box.ovf...
    virtualbox-iso.vm (vagrant): Compressing: Vagrantfile
    virtualbox-iso.vm (vagrant): Compressing: alpine-3.21-amd64-disk001.vmdk
    virtualbox-iso.vm (vagrant): Compressing: box.ovf
    virtualbox-iso.vm (vagrant): Compressing: metadata.json
Build 'virtualbox-iso.vm' finished after 2 minutes 31 seconds.

==> Wait completed after 2 minutes 31 seconds

==> Builds finished. The artifacts of successful builds are:
--> virtualbox-iso.vm: 'virtualbox' provider box: ./packer_templates/../builds/alpine-3.21-x86_64.virtualbox.box

└─$ ls -lh builds/alpine-3.21-x86_64.virtualbox.box
-rw-r--r-- 1 jlst sysadmins 193M May  4 10:20 builds/alpine-3.21-x86_64.virtualbox.box

└─$ vagrant box add --name rudy/Alpine-3.21.3-BIOS-x86_64-vb_7-0-22 ./builds/alpine-3.21-x86_64.virtualbox.box --force
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'rudy/Alpine-3.21.3-BIOS-x86_64-vb_7-0-22' (v0) for provider: 
    box: Unpacking necessary files from: file:///Extra/vguest_img/Vagrant/Vagrant.d/jlst/Develop/Vagrant/Bento-Alpine/bento/builds/alpine-3.21-x86_64.virtualbox.box
==> box: Successfully added box 'rudy/Alpine-3.21.3-BIOS-x86_64-vb_7-0-22' (v0) for ''!

Somewhere on the system host:

└─$ vagrant init rudy/Alpine-3.21.3-BIOS-x86_64-vb_7-0-22

└─$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /Extra/vguest_img/Vagrant/Vagrant.d/jlst/Develop/Vagrant/vagrant-testing-boxes/Alpine-t1 => /vagrant
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.

└─$ vagrant ssh
Welcome to Alpine Linux!
alpine:~$ pwd
/home/vagrant
alpine:~$ ls -ld /home/vagrant
drwxr-sr-x    3 vagrant  vagrant       4096 May  4 10:36 /home/vagrant
alpine:~$

└─$ vagrant halt
==> default: Attempting graceful shutdown of VM...

Hope this will help,
Rudy

Joel Soete added 2 commits May 4, 2025 10:00
Adapt os_pkrvars/alpine/alpine-3.21-x86_64.pkrvars.hcl in accordance;
Otoh, as alpine deprecated sudo and replaced by doas which require
a tty to operate, we should better use ssh_user=root for
the initialization of the 'box'.

On branch my-conrib_4_apline-vbox
Changes to be committed:
	modified:   os_pkrvars/alpine/alpine-3.21-x86_64.pkrvars.hcl
	new file:   packer_templates/http/alpine/answers
	modified:   packer_templates/pkr-builder.pkr.hcl
	modified:   packer_templates/pkr-sources.pkr.hcl
were taken form: <https://github.com/SamuelMarks/alpine-packer/tree/3.21>

On branch my-conrib_4_apline-vbox
Changes to be committed:
	modified:   packer_templates/pkr-builder.pkr.hcl
	new file:   packer_templates/scripts/alpine/x-apk-update.sh
	new file:   packer_templates/scripts/alpine/x-only-virtualbox.sh
	new file:   packer_templates/scripts/alpine/x-only-vmware.sh
	new file:   packer_templates/scripts/alpine/x-provision.sh
	new file:   packer_templates/scripts/alpine/x-vmdiskclean.sh
@rubisher rubisher marked this pull request as draft May 6, 2025 09:28
@rubisher rubisher marked this pull request as ready for review May 6, 2025 09:29
@rubisher rubisher marked this pull request as draft May 6, 2025 09:47
@rubisher
Copy link
Author

rubisher commented May 6, 2025

MMM sorry I don't find how to 'assign' this pr to Samuel?

@rubisher rubisher marked this pull request as ready for review May 6, 2025 09:55
@SamuelMarks
Copy link
Owner

@rubisher Thanks, I've pushed your ssh_username and boot_command values to:

  • os_pkrvars/alpine/alpine-3.21-aarch64.pkrvars.hcl
  • os_pkrvars/alpine/alpine-3_21-aarch64.pkrvars.hcl

Then running:

$ gem install bento-*.gem
$ gem build bento.gemspec
$ bento build --cpus 2 os_pkrvars/alpine/alpine-3.21-aarch64.pkrvars.hcl

Gives:

2025-05-09T09:30:30-06:00: ==> virtualbox-iso.vm: Waiting 10s for boot...
2025-05-09T09:30:33-06:00: ==> vmware-iso.vm: error starting virtual machine: VMware error: 2025-05-09T09:30:30.407| ServiceImpl_Opener: PID 5884                                                 
==> vmware-iso.vm: Error: The operation was canceled                                             
2025-05-09T09:30:33-06:00: ==> vmware-iso.vm: Waiting 1.537977292s to give VMware time to clean up...                                                                                             
2025-05-09T09:30:35-06:00: ==> vmware-iso.vm: Deleting output directory...
2025-05-09T09:30:35-06:00: Build 'vmware-iso.vm' errored after 6 seconds 599 milliseconds: error starting virtual machine: VMware error: 2025-05-09T09:30:30.407| ServiceImpl_Opener: PID 5884    
Error: The operation was canceled                                                                
2025-05-09T09:30:40-06:00: ==> virtualbox-iso.vm: Typing the boot command...
2025-05-09T09:31:31-06:00: ==> virtualbox-iso.vm: Using SSH communicator to connect: 127.0.0.1
2025-05-09T09:31:31-06:00: ==> virtualbox-iso.vm: Waiting for SSH to become available...

TL;DR neither VMware nor VirtualBox correctly build for me. Happy to debug together

@SamuelMarks SamuelMarks mentioned this pull request May 12, 2025
11 tasks
@rubisher
Copy link
Author

rubisher commented May 14, 2025

virtualbox

Hello @SamuelMarks,
Unfortunately I just have very few knowledge of macos (a colleague of mine is a fan) nor vmware (only begin to install this last one on a fresh OpenSUSE leap on I9 platform)
That said, the 2 problems looks like totally different:

  • about vmware, the VM doesn't start at all : vmware-iso.vm: Error: The operation was canceled :(
    Do you have access to cmd to test the underlying packer cmd like:
    $ # cd to your local git dir;
    $ packer build -on-error=ask -only=vmware-iso.vm -var-file=./os_pkrvars/alpine/alpine-3.21-aarch64.pkrvars.hcl ./packer_templates
    (the see which is the error?)

  • about virtualbox, the VM is well created but apparently wasn't setup correctly :(
    Also the same if you have access to cmd, could you try this other packer cmd:
    $ # cd to your local git dir;
    $ packer build -on-error=ask -only=virtualbox-iso.vm -var-file=./os_pkrvars/alpine/alpine-3.21-aarch64.pkrvars.hcl ./packer_templates
    The option "-on-error=ask" would let you the time to open the Virtualbox GUI and 'Show' would open a console terminal which would allow you to learn more about what happen?

PS:

  1. think twice, on Linux, installing VmWare & Virtualbox on a same system seems to be possible but not using each in the same time like the above "bento" cmd looks like to do (but I don't know about macos :()
  2. I own some Raspberry PI ( 4 & 5 ) but don't if it is possible to install either VmWare Workstation or Virtualbox?

Hope this will help to debug the problems ;)

Happy session,
Rudy

@SamuelMarks
Copy link
Owner

@rubisher So have you been able to get the build working on your system? - Which OS and hypervisor(s)?

BTW: Just merged in my latest changes; merged latest main; and pushed to this branch.

@rubisher
Copy link
Author

rubisher commented Jun 8, 2025

@rubisher So have you been able to get the build working on your system? - Which OS and hypervisor(s)?

BTW: Just merged in my latest changes; merged latest main; and pushed to this branch.
Hello @SamuelMarks ,
Yes it works to me:

my Linux install being an OpenSUSE Leap 15.6,
with 'hashicorp' vagrant & packer tools build,
as well as native Oracle VirtualBox

Thanks a lot for all,
Rudy

@SamuelMarks
Copy link
Owner

Let me know if you got it working and on which OS+hypervisor @rubisher

@rubisher
Copy link
Author

rubisher commented Jul 2, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants