Skip to main content

Deploy your testing VM in a couple of sections

Project description

🗲 Ride the Lightning!🗲

Build Status PyPI version

Logo

Virt-Lightning can quickly deploy a bunch of new VM. It also prepares the Ansible inventory file!

This is really handy to quickly validate a new Ansible playbook, or a role on a large number of environments.

example: test an Ansible command on a new env in ONE minute ⚡

In a nutshell:

echo "- distro: centos-7" > virt-lightning.yaml
vl up
vl ansible_inventory
ansible all -m ping -i inventory

In the video below, we:

  1. use the list of distribution to generate a virt-lightning.yaml file.
  2. we then create a environment based on this file
  3. once the environment is ready, we generate an Ansible inventory file
  4. and we use it to call Ansible's ping module on all the host.

demo

Pre-requirements

Debian

First you need to install libvirt and guestfs:

sudo apt install -f libguestfs-tools libvirt-daemon libvirt-daemon-system python3 python3-libvirt python3-pip python3-urwid
sudo systemctl start --now libvirtd

The second step is to grant to your user the ability to use libvirt:

sudo usermod -a -G kvm,libvirt,libvirt-qemu $USER

Fedora-29

First you need to install libvirt and guestfs:

sudo dnf install -f libguestfs-tools libselinux-python libvirt libvirt-daemon python3 python3-libvirt python3-pip python3-urwid
sudo systemctl start --now libvirtd

The second step is to grant to your user the ability to use libvirt:

sudo usermod -a -G qemu,libvirt $USER

Ubuntu-16.04

First you need to install libvirt and guestfs:

sudo apt install -f libguestfs-tools libvirt-bin libvirt-daemon python3 python3-libvirt python3-pip python3-urwid
sudo systemctl start --now libvirtd

The second step is to grant to your user the ability to use libvirt:

sudo usermod -a -G kvm,libvirtd $USER

Ubuntu-18.04

First you need to install libvirt and guestfs:

sudo apt install -f libguestfs-tools libvirt-bin libvirt-daemon python3 python3-libvirt python3-pip python3-urwid
sudo systemctl start --now libvirtd

The second step is to grant to your user the ability to use libvirt:

sudo usermod -a -G kvm,libvirt $USER

Ubuntu-18.10

First you need to install libvirt and guestfs:

sudo apt install -f libguestfs-tools libvirt-daemon libvirt-daemon-system python3 python3-libvirt python3-pip python3-urwid
sudo systemctl start --now libvirtd

The second step is to grant to your user the ability to use libvirt:

sudo usermod -a -G kvm,libvirt $USER

Installation

pip3 install --user --no-deps git+https://github.com/virt-lightning/virt-lightning

The --no-deps argument is only required on Ubuntu (See: https://github.com/pypa/pip/issues/4222).

virt-lightning will be installed in ~/.local/bin/. Add it in your $PATH if it's not already the case. For instance if you use:

echo "export PATH=$PATH:~/.local/bin/" >> ~/.bashrc
source ~/.bashrc

Fetch some images

Before you start your first VM, you need to fetch the images. To do so, you just need these scripts: https://github.com/virt-lightning/virt-lightning/tree/master/images

$ git clone https://github.com/virt-lightning/virt-lightning
$ cd virt-lightning/images
$ ./image centos-7 build
$ ./image debian-9 build
()

Ubuntu requires use sudo to build or prepare images.

You can also use your own images as soon as they embed cloud-init, just copy them in the QCOW2 format in /var/lib/virt-lightning/pool/upstream/. It's also a good idea to include qemu-guest-agent, virt-lightning uses it to set the root password and it offers some other benefits.

Actions

vl is an alias for virt-lightning, you can us both. In the rest of the document we use the shortest version.

  • vl distro_list: List the distro images that can be used. Its output is compatible with vl up. You can initialize a new configuration with: vl distro > virt-lightning.yaml.
  • vl up: virt-lightning will read the virt-lightning.yaml file from the current directory and prepare the associated VM.
  • vl down: Destroy all the VM.
  • vl status: List the VM, their IP and if they are reachable.
  • vl ansible_inventory: Export an inventory in the Ansible format.
  • vl ssh: Show up a menu to select a host and open a ssh connection vl ssh
  • vl console: Like vl ssh but with the serial console of the VM vl ssh

Configuration from file

You can create your own configuration file like this and save to config.ini

[main]
network_name = virt-lightning
root_password = root
storage_pool = virt-lightning

ESXi

You can use virt-lightning with ESXi 6.5 and 6.7. You can build your images with the scripts from the images/extras/ directory:

cd images/extras/
bash esxi-6.5
bash esxi-6.7

ESXi requires a bit more memory than the other systems. You can adjust your virt-lightning.yaml file to overwrite the default (768MB). The key is called memory:

- distro: esxi-6.5
  memory: 14096
  swap: 0
- distro: esxi-6.7
  memory: 4096

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

virt-lightning-1.0.0.tar.gz (67.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page