I've got a standard Vagrant precise64 box. I want to add a number of packages, say git and subversion and then repackage the box. How can I use the package command to create a new box?
I know package is a plugin in v2. This doc was remove in v2 and I'm not sure how it applies
http://docs-v1.vagrantup.com/v1/docs/base_boxes.html
If I try in my directory containing the vagrant machine and the Vagrant file I get:
$ vagrant package boxname --output test.box --vagrantfile Vagrantfile
The machine with the name 'boxname' was not found configured for
this Vagrant environment.
Edit:
The following works
$ vagrant package --output vagrant_example.box
Which leaves me with the following questions. What is the boxname for? What does the base command do? Thanks.
I've hand crafted a couple of Vagrant base boxes (as well as using Veewee). AFAIR, the command format hasn't changed since 1.0.x.
In your case, you may have to init and up the box first, do your job and then re-package it. So the boxname (--base NAME) is the name in VirtualBox, you can get the name by using VBoxManage list vms.
vagrant package --output vagrant_example.box works because it is packaging the current vagrant box (you are in the directory where the Vagrantfile resides).
See the docs http://docs.vagrantup.com/v2/cli/package.html
--base NAME - Instead of packaging a VirtualBox machine that Vagrant manages, this will package a VirtualBox machine that VirtualBox manages. NAME should be the name or UUID of the machine from the VirtualBox GUI.
Related
I was using Vagrant under Windows 10 Pro first with Virtualbox provider and created a few boxes. Then because I wanted to test Docker for Win, I had to switch to Hyper V and uninstall Virtualbox. After some time I manually deleted some Virtualbox machines or re-purposed the folders so they don't have Vagrantfile anymore in them.
When I try to run either
vagrant global-status --prune
or
vagrant destroy -f XXXYYYZZZ
I get this error:
The provider 'virtualbox' that was requested to back the machine 'default' is reporting that it isn't usable on this system. The reason is shown below:
Vagrant could not detect VirtualBox! Make sure VirtualBox is properly installed. Vagrant uses the VBoxManage binary that ships with VirtualBox, and requires this to be available on the PATH. If VirtualBox is installed, please find the VBoxManage binary and add it to the PATH environmental variable.
I understand what Vagrant is trying to say: Install virtualbox binary so it can manage the boxes. But actually there are no VMs to begin with so it should be enough to delete it from registry and for that no Virtualbox is necessary. Is there a way how to remove cached boxes from registry in my case?
vagrant is keeping the list of machines it manages under the following location (that is for Mac, you would need to find for windows as I am not fully sure about the path)
~/.vagrant.d/data/machine-index
and under this folder, you'll find a index file that will list all machines it has in cache. its a JSon file and the provider for the machine is listed so you can remove anything that is not VirtualBox
I got the similar situation when I try to install Docker on my Windows 10 machine with vagrant + virtual box.
I have uninstalled virtual box, but the same error continues every time I try to run "vagrant up"
The provider 'virtualbox' that was requested to back the machine
'default' is reporting that it isn't usable on this system. The reason
is shown below:
Vagrant could not detect VirtualBox! Make sure VirtualBox is properly
installed. Vagrant uses the VBoxManage binary that ships with
VirtualBox, and requires this to be available on the PATH. If
VirtualBox is installed, please find the VBoxManage binary and add
it to the PATH environmental variable.
So below process saved me from it.
step 1: Add below line in vagrantfile below line "config.vm.box"
config.vm.define "hyperv"
Step 2: start your vagrant box calling like below from powershell or cmd
vagrant up --provider=hyperv
It should work. I got the vagrant running after these steps.
It must be the provider which is saved as virtual box somewhere in cache or registry.enter code here
source: https://willmurphyscode.net/2017/01/16/a-very-simple-vagrant-deployment/
My vagrant version is:
$ vagrant --version
Vagrant version 1.0.1
Following these instructions, vagrant init works:
$ vagrant init chef/centos-6.6
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.
But vagrant up can't find the box:
$ vagrant up
There was a problem with the configuration of Vagrant. The error message(s)
are printed below:
vm:
* The box 'chef/centos-6.6' could not be found.
What is the way to configure vagrant, or the command line option, to use chef/centos-6.6?
Chef has removed all of their boxes from atlas. They have left a comment here https://atlas.hashicorp.com/chef/ saying:
If you are looking for Bento boxes they now have their own
organization https://atlas.hashicorp.com/bento/
If you trigger a:
vagrant box add chef/centos-6.6
with the outdated source (chef) it will provide feedback leading to bento as the new source, something along the lines of:
Name: bento/centos-6.6
Provider: virtualbox
Version: 2.2.0
This eventually makes more concrete what is written on the site at the chef atlas link, that the command in your question shall now instead be:
$ vagrant init bento/centos-6.6
(replacing chef by bento)
Some time ago hashicorp moved their images to atlas. Boxes are now downloaded here:
https://atlas.hashicorp.com/boxes/search
Your box is here:
https://atlas.hashicorp.com/chef/boxes/centos-6.6
I can download the box with Vagrant 1.7.2. You are using 1.0.1.
So i think it's a version issue. You have to install a newer version.
I know this is a stupid question, I'm still struggling to grok vagrant.
I run vagrant on a windows host, and I'm building Linux guest VMs using VirtualBox. My guest VM is running, and now I want to package it.
The Vagrant documentation says "A common misconception is that the --vagrantfile option will package a Vagrantfile that is used when vagrant init is used with this box. This is not the case. Instead, a Vagrantfile is loaded and read as part of the Vagrant load process when the box is used. For more information, read about the Vagrantfile load order."
Got it. But that's what I want to do! When I run "vagrant package --output myboxname.box", my carefully-crafted Vagrant file does not appear to be in the package. I test the box as follows (in Windows, after copying the new box):
cd \some_new_dir
vagrant box add myboxname.box --name boxname
vagrant init boxname
The new Vagrantfile is the generic vagrant version, with none of my changes.
When I
vagrant up
The vm comes up fine, but (not surprisingly) none of Vagrantfile directives have happened.
I know I'm missing something basic -- can someone please help me out?
Try copying the Vagrantfile from the directory you ran vagrant package in to the \some_new_dir directory. Then, without running vagrant init (because this will overwrite the Vagrantfile with an empty file), run vagrant up to use the Vagrantfile.
I have set up a vagrant vm on my machine. (Virtualbox)
I would like to be able to share this VM amongst other machines however would like to avoid having to download the image repeatedly.
I tried Exporting the Appliance and copying the Vagrantfile folder onto a different machine, however when i tried to connect using vagrant ssh it could not find it. I assume this is because of non-matching UUID's. How can I go around this?
Vagrant version 1.6.3
The solution was to use Vagrant Package
vagrant package --base <Name Of VM on virtualbox>
This creates a package.box file in your current directory.
You then share that package.box file, and on the new computers you execute:
vagrant init package.box
in the directory where the Vagrantfile will be created
What is the syntax for adding a locally existing VirtualBox .vdi to vagrant?
There doesn't appear to be an example of alternate URI schemes in the documentation.
Can it also use ssh and httpauth locations?
You cannot directly "import" a VirtualBox VM into Vagrant.
Basically you'll have to package the existing VirtualBox VM to a box and then add it to vagrant.
NOTE: a box is tarred VirtualBox Exports (could be gzipped).
You would be doing
Package the existing VirtualBox VM (VDI format)
vagrant package --base mybox --output /path/to/mybox.box
See more here => http://docs.vagrantup.com/v2/cli/package.html
Add the box to vagrant
vagrant box add mybox /path/to/mybox.box