16 Managing virtual machines with Vagrant #
Vagrant is a tool that provides a unified workflow for the creation, deployment and management of virtual development environments. The following sections describe how to manage virtual machines by using Vagrant.
16.1 Introduction to Vagrant #
Vagrant provides an abstraction layer for various virtualization providers via a simple configuration file that allows developers and operators to quickly spin up a virtual machine (VM) running Linux or any other operating system.
16.1.1 Vagrant concepts #
Vagrant uses providers
, provisioners
,
boxes
, and Vagrantfiles
as building
blocks of the virtual machines.
- Provider
Services to set up and create virtual environments. Vagrant ships with support for VirtualBox and Microsoft Hyper-V virtualization. Other services such as
libvirt
, VMware or AWS are supported via plug-ins.- Provisioner
Tools to customize the configuration of virtual environments. Vagrant has built built-in providers for uploading files, synchronizing directories or executing shell commands, but also supports configuration management systems such as Ansible, CFEngine, Chef, Puppet, and Salt.
- Vagrantfile
Configuration file and file name (
Vagrantfile
) for virtual environments. It contains machine and software requirements and all necessary steps in order to create a development-ready box.- Box
Format and an extension (
*.box
) for virtual environments. Boxes can be downloaded from the Vagrant Cloud and copied from one machine to another in order to replicate an environment.SUSE provides official Vagrant Boxes for SUSE Linux Enterprise using the VirtualBox and
libvirt
providers. SUSE Linux Enterprise Server boxes are available for the AMD64/Intel 64 and AArch64 architectures.
16.1.2 Vagrant example #
A new VM can be launched with Vagrant via the following set of commands. This example uses the official Vagrant box for openSUSE Tumbleweed which is available from the Vagrant Cloud.
Download the Vagrant box for openSUSE Tumbleweed:
vagrant
init opensuse/Tumbleweed.x86_64
This also registers the box with Vagrant and creates the
Vagrantfile
.(Optional) Edit the
Vagrantfile
to customize the environment.Start the box:
vagrant
up
Access the box through
ssh
:vagrant
ssh
16.2 Vagrant boxes for SUSE Linux Enterprise #
Starting with SUSE Linux Enterprise 15 SP2, SUSE provides official Vagrant boxes for
SUSE Linux Enterprise using the VirtualBox and libvirt
providers. SUSE Linux Enterprise Server boxes are
available for the AMD64/Intel 64 and AArch64 architectures, SUSE Linux Enterprise Desktop only for
AMD64/Intel 64.
These boxes come with the bare minimum of packages to reduce their size and are not registered, thus users need to register the boxes prior to further provisioning.
The boxes are only available for direct download from https://download.suse.com. Therefore, a downloaded box must be manually registered with Vagrant as follows:
vagrant
box add --name SLES-15-SP3 \ /path/to/SLES15-SP3-Vagrant.x86_64-15.3-libvirt-*.vagrant.libvirt.box
The box is then available under the name SLES-15-SP3
and
can be used like other Vagrant boxes:
vagrant
init SLES-15-SP3
vagrant
up
vagrant
ssh
16.3 Further reading #
For more information about Vagrant and its configuration, refer to the official documentation at https://docs.vagrantup.com/.