LinuxCommandLibrary

vagrant

Create and manage virtual machines

TLDR

Create Vagrantfile in current directory with the base Vagrant box

$ vagrant init
copy

Create Vagrantfile with the Ubuntu 20.04 (Focal Fossa) box from HashiCorp Atlas
$ vagrant init ubuntu/focal64
copy

Start and provision the vagrant environment
$ vagrant up
copy

Suspend the machine
$ vagrant suspend
copy

Halt the machine
$ vagrant halt
copy

Connect to machine via SSH
$ vagrant ssh
copy

Output the SSH configuration file of the running Vagrant machine
$ vagrant ssh-config
copy

List all local boxes
$ vagrant box list
copy

SYNOPSIS

vagrant command [options]

PARAMETERS

up
    Brings a Vagrant environment up from nothing. This command will create and configure the virtual machine, install necessary software, and make it ready for use.

halt
    Stops the running Vagrant environment.

reload
    Restarts the Vagrant machine, reloading the Vagrantfile configuration.

ssh
    Connects to the Vagrant machine via SSH.

destroy
    Stops and deletes all traces of the Vagrant machine.

init [box-name]
    Initializes a new Vagrant environment by creating a Vagrantfile. An optional box-name can be specified to initialize with a specific base image.

status
    Outputs the status of the Vagrant environment (running, halted, etc.).

box
    Manages Vagrant boxes (base images). Subcommands include `add`, `list`, `remove`, `update`.

--version
    Shows the current Vagrant version.

DESCRIPTION

Vagrant is a tool for building and managing virtual machine environments in a single workflow. With an easy-to-use workflow and focus on automation, Vagrant lowers development environment setup time, increases development/production parity, and makes the "works on my machine" excuse a relic of the past. Vagrant abstracts away the underlying virtualization provider, such as VirtualBox, VMware, or Hyper-V, allowing you to use the same configuration to provision environments across different platforms.

It primarily uses a 'Vagrantfile' which describes the kind of machine you want, the software that needs to be installed, and how you want to access the machine. Running `vagrant up` creates and configures virtual machines according to this file, simplifying the creation of reproducible development environments.

Vagrant is commonly used by developers to create consistent development environments, by operations engineers to standardize infrastructure configurations, and by designers to build isolated environments for running applications. It promotes infrastructure as code, ensuring consistency and repeatability across different environments.

CAVEATS

Vagrant requires a virtualization provider like VirtualBox, VMware, or Hyper-V to be installed on the host machine. The Vagrantfile must be present in the current directory or a parent directory for most commands to function correctly. Some commands may require administrative privileges.

PLUGINS

Vagrant has a plugin system to extend functionality. Many plugins exist for provisioning, networking, and more. Use `vagrant plugin install ` and `vagrant plugin uninstall ` to manage them.

HISTORY

Vagrant was created by Mitchell Hashimoto in 2010 and has been under active development since. It was initially designed to simplify the process of setting up development environments for Ruby on Rails projects, but it has since evolved into a versatile tool applicable to a wide range of technologies and workflows.

Its early usage was heavily influenced by the Ruby community, but the increasing adoption of DevOps practices and infrastructure-as-code principles has led to widespread use across different languages and platforms. The project is now open-source and maintained by HashiCorp.

SEE ALSO

docker(1), virsh(1)

Copied to clipboard