Vagrant | Getting started

Inhaltsverzeichnis

Installation

Installing VirtualBox

Install VirtualBox on Windows

Download from here and install as described here.

Install VirtualBox on Linux
$ sudo apt-get install virtualbox
Install VirtualBox on Mac OS
$ brew cask install virtualbox

Install Vagrant

Install Vagrant on Windows

Download from here and install as described here.

Install Vagrant on Linux
$ sudo apt-get install vagrant
$ sudo apt-get install virtualbox-dkms
Install Vagrant on Mac OS
$ brew cask install vagrant
$ brew cask install vagrant-manager
$ brew cask install vagrant-completion

First Steps

Getting vagrant machine up

$ vagrant box add precise32 http://files.vagrantup.com/precise32.box
$ vagrant box add hashicorp/precise64

Configure Project

$ mkdir vagrant_project 
$ cd vagrant_project

 

Configure Vagrant environment

Running X Clients

Allow X-Forwarding

Vagrant.configure(2) do |config|
   ...
   config.ssh.forward_x11 = true
end

Check ssh config

$ vagrant ssh-config
Host some_site
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile vagrant.d/insecure_private_key
IdentitiesOnly yes
LogLevel FATAL
ForwardX11 yes

Run a X client

$ vagrant ssh
vagrant@vagrant: $ sudo apt-get install xclock
vagrant@vagrant: $ exit
$ ssh -X -p 2222 vagrant

@localhost

 xclock

Setup Vagrant box

Setup with on command

$ vagrant init hashicorp/precise64

Setup manuell

$ vagrant init

Edit the Vagrantfile in this directory and replace

config.vm.box = "precise32"

Start Vagrant box

$ vagrant up

Connect using SSH

$ vagrant ssh

Stop working with Vagrant

$ vagrant halt

Destroy the machine

$ vagrant destroy