Application "Vagrant"

From SMW CindyKate - Main
Component 331456
Jump to: navigation, search


Use Cases

Use Case "Associate a Vagrant project directory with an existing VirtualBox VM"

  1. Run VBoxManage list vms
  2. Copy the corresponding VM's id, e.g. 79241e6b-59c4-4bda-beff-ad6df318146a
  3. Create <project-directory>/.vagrant/machines/<vagrant-name>/virtualbox/id containing nothing but the copied VM id on the first line

Use Case "Move/copy a vagrant-controlled VM (environment) to a new workstation maintaining vagrant functionality"

Let's say you want to move a vagrant-controlled mymachine on workstation_A

[email protected]_A:~/mymachine$ tree
└── Vagrantfile


[email protected]_B:~/mymachine$ tree
└── Vagrantfile

and be able to do

[email protected]_B:~/mymachine$ vagrant up
[email protected]_B:~/mymachine$ vagrant ssh

as if mymachine had been created on workstation_B.

Step 1: Package

Package mymachine into a Vagrant box (see

[email protected]_A:~/mymachine$ vagrant package --output --vagrantfile Vagrantfile

It will take some time to pack

[email protected]_A:~/mymachine$ tree
├──   # <-- This is the file that is created.
└── Vagrantfile
Notice: now includes [email protected]_A:~/mymachine/Vagrantfile

Step 2: Move/Copy


[email protected]_A:~/mymachine/


[email protected]_B:~/mymachine/

Step 3: Initialize

Run (see

[email protected]_B:~/mymachine$ vagrant init --minimal

This will create a minimal [email protected]_B:~/mymachine/Vagrantfile that looks like this

Vagrant.configure("2") do |config| = ""

Step 4: Start


[email protected]_B:~/mymachine$ vagrant up --no-provision

This will start mymachine using settings found in

  1. [email protected]_B:~/mymachine/Vagrantfile
  2. the Vagrantfile included in the box (see step 1)

You can override settings in Vagrantfile included in the box with settings specified in [email protected]_B:~/mymachine/Vagrantfile.


  • In case the Vagrantfile included in the box (see step 1) specifies e.g. shared folders or provisioners, Vagrant will prompt you to add these resources.
  • The Vagrantfile included in the box can usually be viewed at [email protected]_B:~/.vagrant.d/boxes/


In case you get

==> default: Machine booted and ready!
[default] GuestAdditions versions on your host (5.0.26) and guest (5.0.18) do not match.
The following packages will be upgraded:
E: Archives directory /vagrant/cache/apt/partial is missing. - Acquire (2: No such file or directory)

try this

[email protected]:~/mediawiki-vagrant$ vagrant ssh
[email protected]:~$ mkdir -p /vagrant/cache/apt/partial
[email protected]:~$ exit
[email protected]:~/mediawiki-vagrant$ vagrant halt && vagrant up