How to show Vagrant box version used in a particular directory
I have multiple Vagrant boxes, and would like to see what version of what box is running in which directory.
vagrant box list
returns a global list of boxes:
puphpet/centos65-x64 (virtualbox, 1.2.1)
puphpet/centos65-x64 (virtualbox, 2.0)
vagrant global-status
shows directories with providers:
id name provider state directory
--------------------------------------------------
a427238 default virtualbox poweroff /path/to/dir1
fa21751 default virtualbox running /path/to/dir2
But how can I see which Vagrant box version is used in which directory?
This data is possible to retrieve but is not exposed, as far as I know, through the Vagrant CLI. Take a look in ~/.vagrant.d/data/machine-index/index
for Linux or macOS and I would assume it'd be something like C:Userswhoever.vagrant.ddatamachine-index
on Windows.
You'll get some unformatted JSON which contains details on every machine Vagrant knows about. If you run the JSON through a pretty-printer/beautifier you'll get one of these for every machine:
"d62342a255436211725abe8fd3c313ea": {
"local_data_path": "/Users/whoever/mymachine/.vagrant",
"name": "default",
"provider": "virtualbox",
"state": "poweroff",
"vagrantfile_name": null,
"vagrantfile_path": "/Users/whoever/mymachine",
"updated_at": null,
"extra_data": {
"box": {
"name": "ubuntu/xenial64",
"provider": "virtualbox",
"version": "20170706.0.0"
}
}
},
And the box information associated with your machine is right there. The ubuntu/xenial64
box on the virtualbox
provider version 20170706.0.0
.