Skip to content
Starts your VM on libvirt in a couple of seconds!
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ansible ansible: use the virt_lightning role Mar 8, 2019
conf retrieve network configuration from libvirt net Feb 15, 2019
images
logo import the logo Feb 27, 2019
tests
virt_lightning don't hide exception May 13, 2019
.gitignore gitignore: ignore the local copy of the Ansible role Mar 8, 2019
.travis.yml add libvirt-python in the requirements.txt Feb 13, 2019
DEBUGING.md doc: clarify the main README Feb 28, 2019
LICENSE-2.0.txt python package Feb 9, 2019
MANIFEST.in python package Feb 9, 2019
README.md esxi: refresh the documentation Mar 22, 2019
README.md.j2 esxi: refresh the documentation Mar 22, 2019
refresh_readme.py README: partially generate the file from Ansible vars Feb 19, 2019
requirements.txt drop the support qemu:///session Feb 27, 2019
setup.py use setuptool_scm plugin to main version Feb 20, 2019
test-requirements.txt tox: reorganize the test deps and enable coverage Feb 27, 2019
tox.ini tox: catch changes on README.md.j2 Feb 28, 2019

README.md

🗲 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
You can’t perform that action at this time.