I have a VirtualBox VM, created "by hand" (i.e., without using vagrant at all), which runs Debian.
What is the simplest way to generate a vagrant file that would replicate this box? Is there an automated way to do this?
I have a VirtualBox VM, created "by hand" (i.e., without using vagrant at all), which runs Debian.
What is the simplest way to generate a vagrant file that would replicate this box? Is there an automated way to do this?
You can try following the steps reported in the github page "Convert a VirtualBox .ova
VM into a Vagrant box
#7", skipping the first one because you already have your VM (and you are not starting from an ova
file)...
Individuate the internal name, ID, reading it from the GUI or by commandline with the VBoxManage
command:
VBoxManage list vms
"UCS 4.1" {acef4c0a-35be-4640-a214-be135417f011}
You are interested in acef4c0a-35be-4640-a214-be135417f011
, that on your computer will be different (instead of UCS 4.1 you have to select the VM name you given to your debian system).
Package that VM as a Vagrant box
vagrant package --base acef4c0a-35be-4640-a214-be135417f011 --output UCS.box
Take the unique ID found before and write instead of acef4c0a-35be-4640-a214-be135417f011
in the above command line. Note that you can change the output filename as you want (instead of UCS.box
you can use whatever.box
), but you will need to use the same name in the next command.
Add to the list of your local Vagrant boxes
vagrant box add UCS.box --name UCS
With the file name chosen before you can add the box to vagrant
, choosing even the human readable name (in the above case UCS). The name has to be reported in the next file.
Create a Vagrantfile to use this box, or modify one you already have:
Vagrant.configure("2") do |config|
config.vm.box = "UCS"
# ...
end
vagrant up
VBoxManage list vms
. It will answer with the list of the already present VM. Take the strange number (acef4c0a...) associated with the "human readable" one (it will be different on your computer... then continue to use the other commands... You can change the names but you have to change even in the next step (see the bold part to understand better).
config.ssh.insert_key = false
and follow this answer to remove ssh problems: "Warning: Authentication failure. Retrying... " after packaging box
Commented
Nov 19, 2020 at 18:15