Vagrant Overview for MariaDB Users
Vagrant is a tool to create and manage development machines (Vagrant boxes). They are usually virtual machines on the local host system, but they could also be Docker containers or remote machines. Vagrant is open source software maintained by HashiCorp and released under the MIT license.
Vagrant benefits include simplicity, and a system to create test boxes that is mostly independent from the technology used.
In this page we discuss basic Vagrant concepts.
A Vagrant machine is compiled from a Vagrantfile.
A box is a machine that we use as the base for another Vagrant machine. For example, we can use an Ubuntu box as a base to build a Vagrant machine with MariaDB running on Ubuntu.
A provider, which is responsible to providing the virtualization technology that will run our machine.
A provisioner is responsible for installing and configure the necessary software on a newly created Vagrant machine.
A Vagrantfile is a file that described how to create one or more Vagrant machines. Vagrantfiles use the Ruby language, as well as objects provided by Vagrant itself.
A Vagrantfile is often based on a box, which is usually an operating system in which we are going to install our software. For example, one can create a MariaDB Vagrantfile based on the
ubuntu/trusty64 box. A Vagrantfile can describe a box with a single server, like MariaDB, but it can also contain a whole environment, like LAMP. For most practical use cases, having the whole environment in a single box is more convenient.
Boxes can be searched in Vagrant Cloud. Most of their Vagrantfiles are available on GitHub. Searches can be made, among other things, by keyword to find a specific technology, and by provider.
A provider adds support for creating a specific type of machines. Vagrant comes with several providers, for example:
- VirtualBox allows to create virtual machines with VirtualBox.
- Hyper-V allows to create virtual machines with Microsoft Hyper-V.
- Docker allows to create Docker containers.
Alternative providers are maintained by third parties or sold by HashiCorp. They allow to create different types of machines, for example using VMWare.
To find out how to develop your own provider, see Plugin Development: Providers in Vagrant documentation.
Some examples of useful providers, recognised by the community:
- Vagrant AWS Provider.
- Vagrant Google Compute Engine (GCE) Provider.
- Vagrant Azure Provider.
A provisioner is a technology used to deploy software to the newly created machines.
The simplest provisioner is
shell, which runs a shell file inside the Vagrant machine.
powershell is also available.
Other providers use automation software to provision the machine. There are provisioners that allow to use Ansible, Puppet, Chef or Salt. Where relevant, there are different provisioners to allow to use these technologies in a distributed way (for example, using Puppet apply) or in a centralized way (for example, using a Puppet server).
It is interesting to note that there are both a Docker provider and a Docker provisioner. This means that a Vagrant machine can be a Docker container, thanks to the
docker provisioner. Or it could be any virtualisation technology with Docker running in it, thanks to the
docker provisioner. In this case, Docker pulls images and starts containers to run the software that should be running in the Vagrant machine.
This is a list of the most common Vagrant commands. For a complete list, see Command-Line Interface in Vagrant documentation.
To list the available boxes:
vagrant box list
To start a box:
cd /box/directory vagrant up
To connect to a box:
To see all boxes status and their id:
To destroy a box:
vagrant destroy <id>
Here are some valuable websites and pages for Vagrant users.
Content initially contributed by Vettabase Ltd.