Vagrant (software)

from Wikipedia, the free encyclopedia
Vagrant

logo
Screenshot
Vagrant starts a virtual machine on command
vagrant up
Basic data

developer HashiCorp ( Mitchell Hashimoto and John Bender )
Publishing year March 8, 2010
Current  version 2.2.9
( May 7, 2020 )
operating system POSIX ( Linux , Unix , OpenBSD , macOS ), Windows
programming language Ruby
category Software distribution and virtualization
License MIT license
German speaking No
www.vagrantup.com

Vagrant is a free Ruby - application for creating and managing virtual machines . Vagrant allows easy software distribution ( english Deployment ), particularly in the software and web development and serves as a wrapper between virtualization software such as VirtualBox , KVM / QEMU , VMware and Hyper-V , and software configuration management applications or system configuration tools like Chef , Salt Stack and Puppet .

Functionality and concepts

Vagrant is controlled via a shell . Below is a list of the most important Vagrant commands and concepts.

Project initialization

To initialize a folder, you have to select the folder and vagrant initexecute the command , then a so-called "Vagrantfile" with examples and explanations is generated and placed in the folder. The addition vagrant init --minimalcreates a minimal version of the Vagrant file without examples and explanations.

The command vagrant inittakes two parameters of vagrant init [box-name] [box-url]: by specifying a "box-name" can Vagrantfile directly with an appropriate template ( "box") are generated and by "box-url" that is URL (Internet address) indicated on the this box is located and can be downloaded. This information can also be configured in the Vagrant file.

This file can now be configured with any text editor .

Boxing

Boxes are preconfigured (templates) virtual machines at Vagrant. This is intended to speed up the process of software distribution and development. Every box that was used by the user is saved on the computer and does not have to be reloaded from the Internet. Boxes can be explicitly downloaded and removed by the command vagrant box add [box-name]or vagrant box add [box-url]by vagrant box remove [box-name]. A “box name” is structured as follows by convention : “Developer / Box”, for example “hashicorp / precise32”. Vagrant Cloud serves as an exchange platform for searching for boxes and adding your own boxes. If only a box name is given, it is assumed that the box is available locally. Otherwise the box is searched for in the Vagrant Cloud.

configuration

The entire configuration is done in the Vagrantfile. The syntax is based on Ruby .

A syntax example:

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

This is what Vagrant says, configuration version 2 should be used. This is necessary for backward compatibility . The “config” function then determines that Vagrant should use the “hashicorp / precise32” box.

Provisioning

When provisioning , Vagrant calls other programs, mostly SCM software such as Ansible or the Shell . This automates the configuration.

The following provisioners are available in Vagrant: File, Shell, Ansible , CFEngine , Chef Solo, Chef Client, Docker , Puppet Apply, Puppet Agent and Salt .

Syntax example

Vagrant.configure("2") do |config|
 config.vm.box = "hashicorp/precise32"
 config.vm.provision "shell", path: "script.sh"
end

This executes the shell script "script.sh".

A wide variety of provisioners can be executed in one file. Syntax example for several parallel provisioners:

Vagrant.configure("2") do |config|
 config.vm.box = "hashicorp/precise32"
 config.vm.provision "shell", path: "script.sh"
 config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig"
 config.vm.provision "ansible" do |ansible|
  ansible.playbook = "playbook.yml"
 end
end

This runs the shell provisioner, which runs the script.sh file. The file is then moved to the virtual machine under the address “~ / .gitconfig” to “.gitconfig”. The last thing to run is the Ansible provisioner, which executes the "playbook.yml".

Software distribution

From version 1.7 of December 2014 software distribution is possible using the command vagrant pushthrough Heroku , SFTP and FTP , through self-written command line scripts and through the in-house "Atlas".

Syntax example for an FTP push

config.push.define "ftp" do |push|
 push.host = "ftp.test.com"
 push.username = "benutzer1"
 push.password = "Passwort1"
 push.secure = false
 push.destination = "/"
 push.dir = "/"
end

This section carries out a software distribution process using the FTP protocol on the server at the address “ftp.test.com” with the user “User1” and the password “password1”. push.securestates whether the SFTP protocol should be used, set to by default false. push.destinationcontains the target path (on the server) to which the files are to be sent, whereas contains push.dirthe local path to the files which are to be uploaded. All paths are relative to the Vagrantfile. In addition, files and folders can be excludeexcluded or includeincluded using.

Start session

To start the virtual machine, run the command vagrant up. If necessary, vagrant sshan SSH session can then be started with.

End session

The virtual machine can be terminated in a number of ways. The machine can be vagrant destroycompletely "destroyed" with all its dependencies with the command . In addition, the virtual machine can also be vagrant haltstopped and vagrant suspendbrought to an idle state. Otherwise the machine can also be vagrant reloadrestarted with.

Others

With Vagrant, many virtual machines can be operated at the same time, the status of which vagrant global-statuscan be queried with the command .

Versions

As of version 1.1, other virtualization applications such as VMware Player and server environments such as Amazon EC2 are also supported.

With version 1.5, folder synchronization with Rsync and SMB as well as support for Hyper-V for visualization were added.

With version 1.6 Docker is also natively supported at runtime, which is supposed to reduce overhead , since Docker works with LXC .

Version 1.7, released on December 9, 2014, enables simple software distribution using the command vagrant pushthrough Heroku , SFTP and FTP , through self-written command line scripts and through the in-house "Atlas".

Version 1.8 was released on December 21, 2015. This version now uses "linked images" whenever possible , which means that system images no longer have to be duplicated, but can be given as a reference. In addition, can now take snapshots (English snapshots are) created by systems.

Complementary

To accompany the further development of the project, Mitchell Hashimoto and Armon Dadgar founded Hashicorp, Inc. in 2012 .

There is a plugin called vagrant-libvirtthat allows support for Libvirt in Vagrant.

Vagrant Cloud was also presented at the same time as version 1.5 . This cloud makes it possible to work in a team on a virtual machine at the same time and to display it in a browser via HTTPS and offers predefined packages (so-called boxes).

Web links

Individual evidence

  1. Release 2.2.9 . May 7, 2020 (accessed May 8, 2020).
  2. ^ Introducing Vagrant. In: Linux Journal . November 14, 2012, accessed October 26, 2014 (English, Introduction to Vagrant).
  3. Getting Started. Project Setup. In: docs.vagrantup.com. Hashicorp, accessed on November 9, 2014 (Official documentation for initialization in Vagrant).
  4. a b Command Line Interface. vagrant init. In: docs.vagrantup.com. Hashicorp, accessed on November 9, 2014 (Official documentation for the vagrant init command in Vagrant).
  5. a b Boxes. In: docs.vagrantup.com. Hashicorp, accessed November 9, 2014 (Official Documentation on Boxing in Vagrant).
  6. Command line interface. box. In: docs.vagrantup.com. Hashicorp, accessed November 9, 2014 (Official documentation for the box command in Vagrant).
  7. ^ Vagrantfile. In: docs.vagrantup.com. Hashicorp, accessed on November 9, 2014 (English, official documentation for Vagrantfiles in Vagrant).
  8. ^ Vagrantfile. Configuration version. In: docs.vagrantup.com. Hashicorp, accessed on November 9, 2014 (Official documentation for the configuration version in Vagrant).
  9. Provisioning. Configuration version. In: docs.vagrantup.com. Hashicorp, accessed on November 9, 2014 (Official Documentation on Provisioning in Vagrant).
  10. Provisioning. Basic usage. In: docs.vagrantup.com. Hashicorp, accessed on November 9, 2014 (English, official documentation for the basic operation of provisioning in Vagrant).
  11. Provisioning. Configuration version. In: docs.vagrantup.com. Hashicorp, accessed on November 9, 2014 (Official Documentation on Provisioning in Vagrant).
  12. a b Mitchell Hashimoto: Vagrant Push. One Command to Deploy Any Application. In: Vagrant. December 12, 2014, accessed December 13, 2014 .
  13. Getting Started. Up and SSH. In: docs.vagrantup.com. Hashicorp, accessed on November 9, 2014 (Official Documentation for Starting a Virtual Machine in Vagrant).
  14. Command line interface. Teardown. In: docs.vagrantup.com. Hashicorp, accessed November 9, 2014 (Official documentation for exiting Vagrant).
  15. Command line interface. Global status. In: docs.vagrantup.com. Hashicorp, accessed November 9, 2014 (Official Documentation for Viewing Vagrant's Global Status).
  16. Mitchell Hashimoto: Vagrant . Up and running. O'Reilly Verlag, 2013, ISBN 978-1-4493-3583-0 , pp. 13 (American English, free excerpt [PDF; accessed October 2, 2014]).
  17. ^ Peter Cooper: Vagrant: EC2-Like Virtual Machine Building and Provisioning from Ruby. In: rubyinside.com. March 8, 2014, accessed October 23, 2014 .
  18. a b Mitchell Hashimoto: Vagrant 1.5 and Vagrant Cloud. In: Vagrant. March 10, 2014, accessed October 26, 2014 .
  19. Mitchell Hashimoto: Feature Preview: Docker-Based Development Environments. In: Vagrant. April 28, 2014, accessed October 26, 2014 .
  20. Mitchell Hashimoto: Vagrant 1.8. In: HashiCorp . December 21, 2015, accessed December 26, 2015 .
  21. About Us. "HashiCorp's Vision" and "Our Timeline". In: hashicorp.com. Retrieved November 9, 2014 .
  22. ^ Vagrant Libvirt Provider. In: GitHub . Retrieved October 26, 2014 .
  23. ^ Vagrant Cloud website. In: Vagrant. Retrieved October 26, 2014 .