Jump to content

User:Aslingwa/Vagrants

From Wikipedia, the free encyclopedia
Vagrant
Original author(s)Mitchell Hashimoto
Developer(s)Mitchell Hashimoto and John Bender
Initial releaseMarch 8, 2010; 14 years ago (2010-03-08)[1]
Stable release
1.7.4 / July 17, 2015; 9 years ago (2015-07-17)}
Written inRuby
Operating systemLinux, FreeBSD, OS X, and Microsoft Windows
Available inEnglish
TypeConfiguration management
LicenseMixed open-source and proprietary[2]
Websitevagrantup.com

Vagrant is a computer software that creates and configures virtual development environments.[3] It can be seen as a higher-level wrapper around virtualization software such as VirtualBox, VMware, KVM and Linux Containers (LXC), and around configuration management software such as Ansible, Chef, Salt and Puppet.

Since version 1.1, Vagrant is no longer tied to VirtualBox and also works with other virtualization software such as VMware and KVM, and supports server environments like Amazon EC2.[4] Although written in Ruby, it is usable in projects written in other programming languages such as PHP, Python, Java, C# and JavaScript.[5][6]

Since version 1.6, Vagrant natively supports Docker containers, which serve as a substitute for a fully virtualized operating system. This reduces overhead as Docker uses lightweight Linux Containers.[7]

Vagrant plugins also exist, including vagrant-libvirt that adds support for libvirt, [8] vagrant-lxc that adds support for lxc, [9] and vagrant-vsphere that adds support for VMware's ESXi.[10]

History

[edit]

The idea behind Vagrant started in 2009. Mitchell Hashimoto was frustrated building similar development environments for different projects when he was employed by Ruby development shops. He wanted a solution that would enable him to easily set up development environments for new projects and revert back to stable environment states.[11]

In January 2010, Mitchell approached his colleague, John Bender, who valued his idea and offered to join in on the project. Vagrant began with a project name "hobo". The first working prototype was built by January 31, 2010. This prototype loaded virtual machines and supported SSH commands. [11]

Vagrant 0.1.0 was released in March 8, 2010. Interestingly it was planned to release only supporting a single Ubuntu image but John Bender came up with the idea of "box" system about a week before its public release. Later on, this feature turned out to be one of the most critical pieces to Vagrant. Along with this release, Vagrant also launched its mascot named "Vince Chilling".[11]

After a few months from its first release, Carl Lerche, employee at Engine Yard, discovered Vagrant and proposed to offer sponsorship. On October 14, 2010 Engine Yard announced its sponsorship in an article titled "Mitchell Hashimoto Joins Engine Yard OSS Community Grant Program".[11][12]

In March 2012, the first stable version of Vagrant (v1.0) was released. But even before the release of Vagrant 1.0, hundreds of companies had already started using it including Mozilla, RackSpace, LivingSocial, Shopify, OpenStack, EventBrite. From the beginning, Vagrant had kept itself open sourced under the MIT license. [11]

In November 2012, Mitchell formed [HashiCorp] to back the development of Vagrant full-time. HashiCorp builds commercial additions and provides professional support and training for Vagrant. [13]

In January 2013, the new Vagrant logo: A simple "V" built with isometric cubes was launched, replacing its old mascot "Vince Chilling". [14]

Architecture

[edit]
Vagrant Architecture
Feature Model of Vagrant

Vagrant architecture consists of two layers: Core layer and Plugin layer.

Core Layer

[edit]

The core layer consists of the most inner kernel of Vagrant which specifies the core component of the system such as machines. It also represents the interface to the actual virtual machine. The core layer is made up of components like box, vagrantfile, command line interface, provisoner, provider, and plugin.

Box

[edit]

Box is a packaged format of virtual machine in a Vagrant environment. It is a Vagrant compatible file which can be used by anyone on any system with Vagrant installed in it. Vagrant maintains a set of [predefined boxes] for public use. These boxes can also be customized as per user preference.[15] [16]

Vagrantfile

[edit]

A vagrantfile is the central configuration of a Vagrant machine for the end-user. In this file all kinds of settings such as the provider and provisioner can be specified. If two users share the same vagrantfile, then the two users will possess the same configured Vagrant environment. [16]. Vagrant is meant to run with one vagrantfile per project and the vagrantfile is supposed to be committed to version control. This allows other developers involved in the project to check out the code and customize the vagrantfile as per the use. Code inside vagrantfile is written in Ruby. [17]

Syncing

[edit]

Vagrant provides the ability to sync up the Vagrant folder on different host machines. This enables the user to work on different host machines without the need to re-configure it. By default, Vagrant shares the project directory i.e. /Vagrants. It uses NFS, Rsync, SMB, Virtual Box to enable syncing up of folders. [16][18][19][20][21][22]

Multi-Machine

[edit]

Vagrant provides multi-machine feature which enables the user to setup Vagrant environment with multiple virtual machines. This configuration is done in vagrantfile, wherein the user can specify virtual machine instance and assign name to them. Setting up of multiple machines is of great use in following scenarios:

  1. To model multi-server architecture such as separate database server and web server.
  2. Modeling a distributed system to test the distributed algorithms. [16] [23]

Providers

[edit]

Providers are used to delegate communication with the virtualized instance. Vagrant, by default, gives support for Virtual Box. It also supports other types of machines such as Docker, Hypervisor, VMWare, etc. In order to use other type of machines, Vagrant has specific plugins developed for this purpose. [16] [24]

Provisioner

[edit]

Provisioner helps the user to install the software and configure the machine as per the user customization. This helps the user to further customize the boxes as per requirement, as the predefined boxes typically aren't built perfectly for the user requirement.[16] [25]

Plugins

[edit]

Vagrant implements most of the additional functionality via plugins. Since Vagrant dogfoods its own plugin API, one can be confident that the interface is stable and well supported. One such plugin is called Vagrant-AWS, which allows Vagrant to control and provision Vagrant machines in EC2 and VPC. [16] [26][27]

Setup

[edit]

In order to set up Vagrant, we create a vagrantfile. This file serves as a root directory of the project and also contains the specifics of the kind of machine and resources needed to run the project. [28]


Vagrant has a built-in command for initializing a directory.


Create a working directory

$ mkdir vagrant_getting_started

Change the directory to the one created above

$ cd vagrant_getting_started

Fire the vagrant init command

$ vagrant init

Once the vagrantfile is created, Vagrant needs to add the boxes in order to run the virtual machine instance. Vagrant provides a list of [predefined boxes].


This command adds the box named precise32 to the Vagrant environment.

$ vagrant box add hashicorp/precise32

After the box has been added to Vagrant, the vagrantfile needs to be changed as shown below.

vi vagrantfile 

Add the following Ruby code. Press i to insert text and esc followed by typing :wq to save and quit.

Vargrant.configure("2") do |config|
    config.vm.box = "hashicorp/precise32"
end

Once the box has been added and mentioned in the vagrantfile, the box can be booted with the following command.

$ vagrant up 

Since Vagrant doesn't run a UI, the connection to the virtual machine instance is made using SSH protocol.

$ vagrant ssh

Uses

[edit]
Funcation View of Vagrant
Context View of Vagrant

Developer

[edit]

Vagrant allows developers to isolate dependencies and their configuration within a single disposable, consistent environment. The vagrantfile consists list of tools that should be installed into the boxes. With the help of the command vagrant up everything gets installed and configured for others to work in development environments of same configuration. Vagrant also works on different platforms like Linux, Mac OS X and Windows. [29]

Operations Engineer

[edit]

Vagrant provides an operations engineer a disposable environment and consistent workflow for developing and testing infrastructure management scripts. It facilitates testing of shell scripts, Chef cookbooks, Puppet modules and more using local virtualization such as VirtualBox or VMWare. Moreover, with the same configuration, testing of scripts on remote clouds such as AWS or RackSpace with the same workflow can also be done. [29]


Useful Commands

[edit]

Following is the list of popular Vagrant commands [16]

Command Description
connect connects to a remotely shared Vagrant environment
destroy stops and deletes all traces of the Vagrant machine
global-status outputs status Vagrant environments for this user
halt stops Vagrant machine
help shows the help for a subcommand
init initializes a new Vagrant environment by creating a vagrantfile
login logs in to HashiCorp's Atlas
package packages a running Vagrant environment into a box
plugin manages plugins: install, uninstall, update, etc.
provision provisions the Vagrant machine
push deploys code in this environment to a configured destination
rdp connects to machine via RDP
reload restarts Vagrant machine, loads new vagrantfile configuration
resume resumes a suspended Vagrant machine
share shares your Vagrant environment with anyone in the world
ssh connects to machine via SSH
ssh-config outputs OpenSSH valid configuration to connect to the machine
status outputs status of the Vagrant machine
suspend suspends the machine
up starts and provisions the Vagrant environment
version prints current and latest Vagrant version

References

[edit]
  1. ^ "mitchellh/vagrant: Release v0.1.0". GitHub. Retrieved 6 September 2015.
  2. ^ HashiCorp (2014-03-03). "Vagrant Installer Generators » master/package/support/windows/license.rtf". GitHub. Retrieved 2014-12-30.
  3. ^ "Introducing Vagrant". Linux Journal. 14 November 2012. Retrieved 2013-10-23.
  4. ^ Mitchell Hashimoto (2013). Vagrant: Up and Running (PDF). O'Reilly Media. p. 13. ISBN 978-1449335830.
  5. ^ "Vagrant: EC2-Like Virtual Machine Building and Provisioning from Ruby". Retrieved May 14, 2012.
  6. ^ "Vagrant - Getting Started - Project Setup". Retrieved September 20, 2012.
  7. ^ HashiCorp (2014-05-06). "Vagrant 1.6". Retrieved 2014-06-14.
  8. ^ "pradels/vagrant-libvirt". GitHub.com. Retrieved 2014-04-03.
  9. ^ "fgrehm/vagrant-lxc". GitHub.com. Retrieved 2014-12-29.
  10. ^ "nsidc/vagrant-vsphere". GitHub.com. Retrieved 2015-05-06.
  11. ^ a b c d e "The Hardest, Most Rewarding Job I've Ever Had". Retrieved September 14, 2015.
  12. ^ "Mitchell Hashimoto Joins Engine Yard OSS Community Grant Program". Retrieved September 14, 2015.
  13. ^ "About Vagrant". Retrieved September 14, 2015.
  14. ^ "A new look for Vagrant". Retrieved September 14, 2015.
  15. ^ "Boxes". Retrieved September 14, 2015.
  16. ^ a b c d e f g h "The Underlying Architecture: Core Layer". Retrieved September 14, 2015.
  17. ^ "Vagrantfile". Retrieved September 14, 2015.
  18. ^ "Synced Folders". Retrieved September 14, 2015.
  19. ^ "NFS". Retrieved September 14, 2015.
  20. ^ "RSync". Retrieved September 14, 2015.
  21. ^ "SMB". Retrieved September 14, 2015.
  22. ^ "Virtual Box". Retrieved September 14, 2015.
  23. ^ "Multi Machine". Retrieved September 14, 2015.
  24. ^ "Providers". Retrieved September 14, 2015.
  25. ^ "Provisioning". Retrieved September 14, 2015.
  26. ^ "Vagrant-AWS". Retrieved September 14, 2015.
  27. ^ "Plugins". Retrieved September 14, 2015.
  28. ^ "Getting Started". Retrieved September 14, 2015.
  29. ^ a b "Why Vagrant". Retrieved September 14, 2015.
[edit]

Category:Cross-platform software Category:Provisioning Category:Virtualization software for Linux