This is how to install something in a VM and export it as a Vagrant box and use it locally.
First copy the Vagrantfile from below and change the box to the box you want as a base.
Run vagrant up
to create the Virtual Machine and vagrant ssh
to login.
On Windows you might have to put ssh.exe to your %PATH%. If you have installed git, you can use C:\Program Files\Git\usr\bin
You can also login via Putty on host: "localhost", Port "2222", login: "vagrant", password: "vagrant".
Now install your software if not already defined in you Vagrantfile.
Exit the VM and run vagrant package --base my-new-box-name --output my-new-box-name.box
. Vagrant will export the actual VM in a file.
Run vagrant box add my-new-box-name file:///c:/path/to/my-new-box-name.box
(relative path does also work: file://my-new-box-name.box) to import your new box.
vagrant box list
will list your new box.
The box-file can be deleted.
Now you can use the box in new Vagrantfiles.
See also Custom Vagrant Cloud Versioned Box Host.
If Vagrant has problems logging in and fails with "Warning: Authentication failure. Retrying..." take a look at Vagrant box authentication failure after packaging box or set the loginmethod to password by adding config.ssh.password = "vagrant"
to your Vagrantfile. See SSH settings for more information.