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

user_0@workstation_A:~/mymachine$ tree
└── Vagrantfile


user_1@workstation_B:~/mymachine$ tree
└── Vagrantfile

and be able to do

user_1@workstation_B:~/mymachine$ vagrant up
user_1@workstation_B:~/mymachine$ vagrant ssh

as if mymachine had been created on workstation_B.

Step 1: Package

Package mymachine into a Vagrant box (see

user_0@workstation_A:~/mymachine$ vagrant package --output --vagrantfile Vagrantfile

It will take some time to pack

user_0@workstation_A:~/mymachine$ tree
├──   # <-- This is the file that is created.
└── Vagrantfile
Notice: now includes user_0@workstation_A:~/mymachine/Vagrantfile

Step 2: Move/Copy





Step 3: Initialize

Run (see

user_1@workstation_B:~/mymachine$ vagrant init --minimal

This will create a minimal user_1@workstation_B:~/mymachine/Vagrantfile that looks like this

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

Step 4: Start


user_1@workstation_B:~/mymachine$ vagrant up --no-provision

This will start mymachine using settings found in

  1. user_1@workstation_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 user_1@workstation_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 user_1@workstation_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

user@workstation:~/mediawiki-vagrant$ vagrant ssh
vagrant@mediawiki-vagrant:~$ mkdir -p /vagrant/cache/apt/partial
vagrant@mediawiki-vagrant:~$ exit
user@workstation:~/mediawiki-vagrant$ vagrant halt && vagrant up