My boxes in the Vagrant Cloud

Martien van den Akker
Nerd For Tech
Published in
6 min readJan 15, 2024

This article was published on blog.darwin-it.nl in 2019. I keep referencing to that and other articles from time to time. Some of them have lost their images. So, I want to save them on my medium blog.

In the last few years I wrote several articles about Vagrant, for instance on how I created a seemless desktop using Vagrant, VirtualBox en MobaXterm. That article I’ll move to Medium as well, when I recreated the images.

In the past I used to create local file based boxes. So, if you wanted to use my projects that I posted on GitHub, you had not only to have the install binaries in a certain folder structure, but also the particular box downloaded in the particular boxes folder.

But, publishing them to the Vagrant cloud is surprisingly easy, of course! Why I didn’t do that before? Well, actually, I started with this by preparing a workshop for colleagues. And to simultaneously download the same box by every participant, did not seem a good idea. So I distributed the vagrant project with all the installers including the box on a stick.

But, for most other cases, for instance when I need to switch to a new laptop, it is a good idea to have them in the cloud.

I found this step by step article that guided me through the process. But, let me go through the process my self.

First you’ll need an account on the Vagrant Cloud. You can get there from the main page of vagrantup.com. And then click on the Find Boxes button:

Create a new account or login, if not already done that.

You’ll land on the Search page:

There you can search for existing boxes. But, to create and upload your own one, click on the Dashboard tab:

There, click the “New Vagrant Box” button:

Here, give the box a name and a short description. My first boxes had a version number in the name. But I found that a bit overdone, because later on you get to define a box version. Click on the Create box button. I would urge you to provide a description that give some base, identifiable information on the box.

Provide a version, it’s smart to start with 1 (it will check it), and possibly a description. Although I find a good base description important, I’m not sure what to write on a first version as a description. For subsequent versions, it seems a good to fill in as well. Like with GitHub/Subversion commit messages.

Within the version, I was looking for an upload button, but you first get to define a provider. So click on the provider button:

In the following page you get to define a provider. Provide virtualbox as a provider name. Vagrant need to be able to recognize and use that. But, there is no poplist, so just a free text field.

I want to upload to the Vagrant Cloud, so the default will suffice. Click on the Continue to upload button:

Using the Browse button, browse to your Vagrant box and have it upload it.

Now, to be able to use the box, and others to discover your box, you’ll need to release it. So go to the versions sub tab, and click on the Release button for the v1 version:

In the following page, click on the release button:

Now my boxes are searchable:

My currently available boxes

To use a box, you can create a Vagrant file with the following reference to the box:

Use Oracle Linux 8 Server with GUI box

Or create a new box in a new folder using a command like vagrant init makker/CO78SwGUI — box-version 1, continued by vagrant up:

c:\data\git\makker\vagrant\ol8_swgui>vagrant init makker/OL8SwGUI --box-version 7
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

You can list boxes with the (sub)command vagrant box list:

c:\data\git\makker\vagrant\ol8_swgui>vagrant box list
makker/OL8SwGUI (virtualbox, 7)

Remove a box with vagrant box remove CO77GUIv1.1:

c:\data\git\makker\vagrant\ol8_swgui>vagrant box remove makker/OL8SwGUI
Removing box 'makker/OL8SwGUI' (v7) with provider 'virtualbox'...

But you can add the freshly created box also using the vagrant box add command:

c:\data\git\makker\vagrant\ol8_swgui>vagrant box add makker/OL8SwGUI --box-version 7
==> box: Loading metadata for box 'makker/OL8SwGUI'
box: URL: https://vagrantcloud.com/api/v2/vagrant/makker/OL8SwGUI
==> box: Adding box 'makker/OL8SwGUI' (v7) for provider: virtualbox
box: Downloading: https://vagrantcloud.com/makker/boxes/OL8SwGUI/versions/7/providers/virtualbox/unknown/vagrant.box
box:
box: Calculating and comparing box checksum...
==> box: Successfully added box 'makker/OL8SwGUI' (v7) for 'virtualbox'!

As can be seen it mentions that it started the download earlier, but I broke it off. It apparently resumes the download.

My current Vagrantfiles have the following declaration of the vagrant box:

...
BOX_NAME="CO78GUIv1.1"
BOX_URL="file://../boxes/CO78SwGUIv1.0.box"
VM_MEMORY = 12288 # 12*1024 MB
...
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box=BOX_NAME
config.vm.box_url=BOX_URL
config.vm.hostname=VM_HOST_NAME
config.vm.define VM_MACHINE
config.vm.provider :virtualbox do |vb|
vb.name=VM_NAME
vb.gui=VM_GUI
vb.memory=VM_MEMORY
vb.cpus=VM_CPUS
...

Based on the suggestion of the Vagrant Cloud:

Vagrant file snippet for box settings

I adapted this as follows:

BOX_NAME="makker/OL8SwGUI"
BOX_VERSION="7" # Oracle Linux 8 Update 7
#BOX_URL="file://c:/Data/Vagrant/boxes/OL8U7SwGUIv1.0.box"
VM_MEMORY = 12288 # 12*1024 MB
...
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = BOX_NAME
config.vm.box_version = BOX_VERSION
# config.vm.box_url=BOX_URL
config.vm.hostname=VM_HOST_NAME
config.vm.define VM_MACHINE
config.vm.provider :virtualbox do |vb|
vb.name=VM_NAME
vb.gui=VM_GUI
vb.memory=VM_MEMORY
vb.cpus=VM_CPUS
...

I uncommented the BOX_URL variable with the config.vm.box_url lines. And added the BOX_VERSION and config.vm.box_version lines. Most importantly I changed the BOX_NAME variable to makker/CO78SwGUI.

These suggestions will download my Cloud boxes without me needing to distributed them separately.

Happy Upping!

Post-note

After writing this article a few years ago, I improved my Vagrant projects a lot, to make them more maintainable. Check out this article for instance: Check out my upgraded Vagrant project. Last week I removed the mentioned repo’s. But, I’ll write a new article on it soon.

Originally published at http://blog.darwin-it.nl.

--

--

Nerd For Tech
Nerd For Tech

Published in Nerd For Tech

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/.

Martien van den Akker
Martien van den Akker

Written by Martien van den Akker

Technology Architect at Oracle Netherlands. The views expressed on this blog are my own and do not necessarily reflect the views of Oracle

No responses yet