You are on page 1of 10

VAGRANT -

CONFIGURATION VIRTUAL ENVIRONMENTs

VAGRANT is
computer software that
creates
and
configures virtual development environments. It can be seen as a higherlevel wrapper around virtualization software such as VirtualBox, VMware and
KVM etc. Vagrant is written in Ruby; it is usable in projects written in
other programming languages such as PHP, Python, Java, C# and JavaScript.
As prerequisites just have to install Vagrant software and any virtual software
such as VMware, VMplayer and VirtualBox etc. Vagrant automatically installs
and configures work environment and software on the machine with no or
minimal efforts towards it.
VAGRANT FEATURES:

Easy to configure

Reproducible

Construct portable work environments

Maximize the productivity

Flexible

Cross Platform

Vagrant will isolate dependencies, configuration and creates a single


disposable, consistent environment, without sacrificing any of the tools used
to working with such as editors, browsers, debuggers, etc. Once a single
Vagrantfile is created, just need to vagrant up and everything is installed
and configured. Other environments can be created using this configuration,
so whether working on Linux, Mac OS X, or Windows, all can run the code in
the

respective

environment.

This

eliminates

Single

machine

work

environment.
INSTALLATION:
Installing Vagrant is extremely easy.

Download latest vagrant software and install in the machine as per


platform http://www.vagrantup.com/downloads.html.

The installer will automatically add vagrant to your system path.

Installer will ask to restart the machine for successful installation.

UNINSTALLATION:
Removing the Vagrant program will remove the vagrant binary and all
dependencies from machine. After uninstalling the program installer ask to
restart the machine for successful uninstallation.

On Windows, uninstall using the add/remove programs section of


the control panel.

On Mac OS X, remove the /Applications/Vagrant directory and


the/usr/bin/vagrant file. Also execute sudo pkgutil --forget
com.vagrant.vagrant to have OS X forget that Vagrant was ever
installed.

On Linux, remove the /opt/vagrant directory and


the /usr/bin/vagrant file.

Removing the user data will remove all boxes, plugins, and any stored state
that may be used by Vagrant. Removing the user data effectively makes
Vagrant think it is once again a fresh install. On every platform, remove
the ~/.vagrant.d directory to delete the user data.
WORKING WITH VAGRANT (Windows) - Running and configuring multiple ID Proxy
instances
Prerequisites: Vagrant software and any of Virtual environments (VirtualBox).Vagrant
runs the virtual machine without a UI so there will not be any GUI for commands to
enter all the commands will execute in CLI.

There are four major commands to work with:

1. Vagrant init - Place Vagrantfile in directory.


2. Vagrant Up Creates virtual machine running in Ubuntu.

3. Vagrant Shh Drop into a full-fledged SSH (Secure Shell)


session.

4. Vagrant destroy - Will remove all traces of the virtual machine.

Vagrant init

Open CLI and Cd to the Directory of Vagrant Vagrant gets installed in


root directory by default.

Launch VirtualBox in the machine.

Run vagrant init in a pre-existing directory or root directory to set up


Vagrant for the project on doing so Vagrantfile is placed in vagrant
directory.

Fig1: vagrant init command to place Vagrantfile in the directory.

Fig2: Vagrantfile structure and placed in directory.

Fig3: Launching VirtualBox, contains empty instances initially

For the purpose of creating multiple ID proxy Instances Edit


'Vagrantfile' and copy the following content in it.

Fig4: Ruby code for creating ID Proxy instances.

Few changes to be made in Vagrantfile listed below and save the file.

1. $num_instance = 1(Increasing this value, creates the number of


instances).
2. $instance_name_prefix = "idproxy"(Define the name of the ID Proxy
instance)
3. $update_channel ="beta"(Defines the channel to pick up images)
a. ALPHA: v1.3.147 (CentOS based image with idproxy service build
147 )
b. BETA: v1.3.145 (CentOs based image with old idproxy service
build 145)
c. STABLE: v1.2.145 (Old Ubuntu based image with old idproxy
service build 145)

Vagrant Up

This will download the latest version of the id proxy image on the
<$update_channel> channel for VirtualBox and instantiate a new VM
named <$instance_name_prefix>

Fig5: Vagrant up initiates creating Virtual environments.

Upon executing vagrant up command, required number of Virtual


environments or instances will be created.

Fig6: Vagrant up command creates Virtual environments in VirtualBox which


are running.

Vagrant Shh

Secure Shell (SSH) or Secure Socket Shell, is a UNIX-based command


interface and protocol for securely getting access to a remote
computer to interact with the machine.

This commands returns secure credentials such as IP address, Port


Number and Username to communicate with Virtual machine.

Fig7: Vagrant SSh returns secure connection details.

Access the Virtual instance either by using PuTTY session or directly in


VirtualBox by providing IP address, Port number, username and

Password.
Once ID proxy instances are up and running, they are associated with
enterprise and configured to Online using LDAP credentials.

Fig8: Accessing Virtual machine using PuTTY session.

Fig9: Accessing Virtual machine through VirtualBox.

Vagrant Destroy

From the same directory where you created the instance(s), run this
command, this will delete all the related VM instances that were
created.
The entire instances will be destroyed in the reverse order at which
they are created.

Fig10: All the Virtual machines will be removed and eventually VirtualBox gets
empty.

PROVIDERS:

Vagrant has the ability to manage other types of machines as well


apart from VirtualBox. This is done by using other providers with
Vagrant.

Alternate providers can offer different features that make more sense
in your use case. For example, if we're using Vagrant for any real
work, VMware providers

are

recommended

since

they're

well

supported and generally more stable and performant than VirtualBox.


Before we can use another provider, you must install it. Vagrant only
ships with VirtualBox support. Installation of other providers is done via

the Vagrant plugin system. Once the provider is installed, usage is


straightforward and simple.