lavabit / robox

The tools needed to robotically create/configure/provision a large number of operating systems, for a variety of hypervisors, using packer.
620 stars 140 forks source link

set MIN_REQUIRED_VAGRANT_VERSION? #288

Closed abbbi closed 8 months ago

abbbi commented 8 months ago

hi there,

i just added the most recent ubuntu2310 images (thanks for that!!) running on a slightly older system where vagrant 2.2.19 was installed. The extracted box images are using another storage layout in terms of the architecture feature (https://developer.hashicorp.com/vagrant/vagrant-cloud/boxes/architecture)

4.3.6/amd64/libvirt

as it stands, older vagrant versions will then simply "ignore" these boxes because they expect the files to be in

4.3.6/libvirt

So with older vagrant versions, adding the boxes works but "vagrant list" will not show them, also "vagrant up" wont work in any way because it attempts to re-add the box (as if not existant ..)

Maybe it makes sense to set MIN_REQUIRED_VAGRANT_VERSION (https://developer.hashicorp.com/vagrant/docs/vagrantfile/vagrant_version) in the released boxes?

As workaround for older vagrant versions simply move the box image contents from the architecture level to the provider level, but i think this might hit quite some users that have not yet updated to 2.4 ..

ladar commented 8 months ago

@abbbi can you vlarify a bit? When you say storage layout, do you mean the virtual disk type and/or partition scheme? Or do you mean the what's inside the box file that Vagrant downloads? The build robot I'm using for libvirt has been using the same Packer version (1.8.5) for awhile now, which means, I believe the Packer plugin which generates the box files hasn't changed.

I iised to run the scripts inside the robox/check directory to verify boxes worked properly, aka vaergrant up && vagrant ssh plus a few basic *nix commands, but the project has gotten too large, and the blades I'm using are simply too slow. That said, the build robot I use for libvirt still happens to have Vegrant 2.2.19 installed, and I just ran a test, and everything worked fine:


[ladar@kristi robox]$ cd check/
[ladar@kristi check]$ vagrant version
==> vagrant: A new version of Vagrant is available: 2.4.0 (installed version: 2.2.19)!
==> vagrant: To upgrade visit: https://www.vagrantup.com/downloads.html

Installed Version: 2.2.19
Latest Version: 2.4.0

To upgrade to the latest version, visit the downloads page and
download and install the latest version of Vagrant from the URL
below:

  https://www.vagrantup.com/downloads.html

If you're curious what changed in the latest release, view the
CHANGELOG below:

  https://github.com/hashicorp/vagrant/blob/v2.4.0/CHANGELOG.md
[ladar@kristi check]$ ./connect.sh generic ubuntu2310 libvirt
==> box: Loading metadata for box 'generic/ubuntu2310'
    box: URL: https://vagrantcloud.com/generic/ubuntu2310
==> box: Adding box 'generic/ubuntu2310' (v4.3.6) for provider: libvirt
    box: Downloading: https://vagrantcloud.com/generic/boxes/ubuntu2310/versions/4.3.6/providers/libvirt/amd64/vagrant.box
    box: Calculating and comparing box checksum...
==> box: Successfully added box 'generic/ubuntu2310' (v4.3.6) for 'libvirt'!
Bringing machine 'default' up with 'libvirt' provider...
==> default: Checking if box 'generic/ubuntu2310' version '4.3.6' is up to date...
==> default: Uploading base box image as volume into Libvirt storage...
==> default: Creating image (snapshot of base box volume).
==> default: Creating domain with the following settings...
==> default:  -- Name:              generic-ubuntu2310-libvirt_default
==> default:  -- Description:       Source: /home/ladar/robox/check/generic-ubuntu2310-libvirt/Vagrantfile
==> default:  -- Domain type:       kvm
==> default:  -- Cpus:              2
==> default:  -- Feature:           acpi
==> default:  -- Feature:           apic
==> default:  -- Feature:           pae
==> default:  -- Clock offset:      utc
==> default:  -- Memory:            2048M
==> default:  -- Base box:          generic/ubuntu2310
==> default:  -- Storage pool:      default
==> default:  -- Image(vda):        /var/lib/libvirt/images/generic-ubuntu2310-libvirt_default.img, virtio, 128G
==> default:  -- Disk driver opts:  cache='default'
==> default:  -- Graphics Type:     none
==> default:  -- Video Type:        cirrus
==> default:  -- Video VRAM:        256
==> default:  -- Video 3D accel:    false
==> default:  -- Keymap:            en-us
==> default:  -- TPM Backend:       passthrough
==> default:  -- INPUT:             type=mouse, bus=ps2
==> default: Creating shared folders metadata...
==> default: Updating domain definition due to configuration change
==> default: Starting domain.
==> default: Waiting for domain to get an IP address...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 192.168.121.15:22
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection reset. Retrying...
    default: Warning: Connection refused. Retrying...
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Running provisioner: shell...
    default: Running: inline script
/usr/bin/xauth:  file /home/vagrant/.Xauthority does not exist
vagrant@ubuntu2310:~$ 

This build robot has Alma 8 installed. More importantly the check.sh and connect.sh scripts downloads/use a localized Vagrant home to store the box, and isntall the vagrant-libvirt plugin, which means the current version of the plugin was used. My guess is the vagrant-libvirt plugin you have installed is the culprit.

ladar commented 8 months ago

It's true that I've started adding support for alternate arches, but ubuntu2310 isn't one of the repos where I';ve added an alternative arch. Even if I had, 2.2.19 would download the default arch (you can't access the alternate using an old version, which is why I started uploading the arches to standalone repos as well). In other words, if you have Vagrant 2.2.19 installed, then nothing will have changed, and the arch feature shouldn't be coming into play. Yes, I'm setting amd64 on upload, but that info is purely for the cloud service, and doesn't actually get stored inside the box file.

abbbi commented 8 months ago

im sorry, the situation was caused by another fact. I use shared storage for the box folder. It appears if i add the boxes with vagrant version 2.4, they are extracted in a way vagrant 2.2.19 cannot handle. So the host which added the box was using version 2.4.0 but on the host running vagran 2.2.19 "vagrant list" wont show them, because they are extracted into the architecture specific subfolders. Sorry for the noise!

ladar commented 8 months ago

@abbbi that actually makes a lot of sense. I've had overhaul the Robox project so that everything is arch aware. Which means lots of name changes, parsing changes, file name changes etc.. Without this, boxes would be clobbering each other all over the place.