Converting virtual-box appliances into vagrant box

It is possible to convert virtual box appliances to vagrant box without much of a hassle. To do so, first you have to import the appliance into your virtual box.

Once imported you can see the VM ID from the virtual media manager.You have to type in the following command in terminal to see the list of virtual boxes and their VM IDs.


vboxmanage list vms

Once you have the VM ID type in the following commands in terminal to export it as a box using vagrant. For example if the VM ID is “acef4c0a-35be-4640-a214-be135417f04d” then the command will be as follows –


vagrant package --base acef4c0a-35be-4640-a214-be135417f04d --output newbox.box

Once the box file is generated you can import in vagrant using the following command –


vagrant box add newbox.box --name newbox

Now in your vagrantfile you can use this “newbox” as the box to be used.


Vagrant.configure("2") do |config|
  config.vm.box = "newbox"
  # ...
end

Reference: https://github.com/crohr/ebarnouflant/issues/7