In local development environments there is always a need for simulation of more powerful environments, as usually happens in the making of demos.
For this we’ll always follow the “KISS” philosophy (keep it simple stupid!) And we will use those services so that our Linux requires the least use of possible resources. We’ll need two tools to simplify the work that are Ansible for deployment and KVM as a hypervisor.
Images for the test environment
The first step is to raise a system that provides us with images in the simplest way possible. We’ll find that Vagrant as a wonderful source of images. We have two ways to use it:
- Download from https://www.vagrantup.com/downloads.html and install (with sudo dpkg -i vagrant_VERSION_x86_64.deb in Debian / Ubuntu environments or with sudo rpm -i vagrant_VERSION_x86_64.rpm in RHEL / Centos environments), to get an image as small as possible we will make use of a debian 9.9.0 with the following command:
$ vagrant box add --provider libvirt debian/stretch64
==> box: Loading metadata for box 'debian/stretch64'
box: URL: https://vagrantcloud.com/debian/stretch64
==> box: Adding box 'debian/stretch64' (v9.9.0) for provider: libvirt
box: Downloading: https://vagrantcloud.com/debian/boxes/stretch64/versions/9.9.0/providers/libvirt.box
box: Download redirected to host: vagrantcloud-files-production.s3.amazonaws.com
==> box: Successfully added box 'debian/stretch64' (v9.9.0) for 'libvirt'!
The downloaded image will be in ~/.vagrant.d/boxes/debian-VAGRANTSLASH-stretch64/9.9.0/libvirt, in the form of three files, being the one that interests us: box.img which is an image with QCOW format.
- Directly download the images that we will use, for example a Centos image: http://cloud.centos.org/centos/7/vagrant/x86_64/images/CentOS-7.Libvirt.box and a Debian image: https://app.vagrantup.com/debian/boxes/stretch64/versions/9.9.0/providers/libvirt.box
To make the deployment easier, Ansible has been configured to download automatically and save the image in /root/.images and use it directly without need to do anything else.
The next thing we need is to download the Ansible tasks that will allow us to launch our test environment, the “package” is formed by a file that will be really important called “inventory.yml”… Read the rest “KVM, Ansible and how to deploy a test environment”