Virt-Lightning can quickly deploy a bunch of new VM. It also prepares the Ansible inventory file!
This is handy to quickly validate a new Ansible playbook, or a role on a large number of environments.
In a nutshell:
echo "- distro: centos-7" > virt-lightning.yaml vl up vl ansible_inventory ansible all -m ping -i inventory
During this recording, we:
python3-urwidif you want to get the fancy list of VM. This dependency is optional.
sudo systemctl start --now libvirtd
virsh -c qemu:///system
pip3 install --user virt-lightning
If you use Ubuntu, you will need the
--no-deps argument (See: https://github.com/pypa/pip/issues/4222).
virt-lightning will be installed in ~/.local/bin/. Add it in your
it's not already the case. For instance if you use:
echo "export PATH=$PATH:~/.local/bin/" >> ~/.bashrc source ~/.bashrc
Before you start your first VM, you need to fetch the images. To do so,
you just use the
vm fetch command:
$ vl fetch fedora-32
vl is an alias for
virt-lightning, you can us both. In the rest of the document
we use the shortest version.
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.
virt-lightning will read the
virt-lightning.yaml file from the current directory and prepare the associated VM.
Destroy all the VM managed by Virt-Lightning.
Start a specific VM, without reading the
Stop just one VM.
List the VM, their IP and if they are reachable.
Export an inventory in the Ansible format.
Show up a menu to select a host and open a ssh connection.
vl ssh but with the serial console of the VM.
vl console but with the SPICE console of the VM. Requires
Fetch a VM image. You can find here a list of the available images.
~/.config/virt-lightning/config.ini exists, Virt-Lightning will read
its configuration there.
[main] network_name = virt-lightning root_password = root storage_pool = virt-lightning network_auto_clean_up = True
network_name: if you want to use an alternative libvirt network
root_password: the root password
storage_pool: if you want to use an alternative libvirt storage pool
networkautoclean_up: if you want to automatically remove a network when running
A VM can be tunned at two different places with the following keys:
distro: the name of the base distro image to use, it's the only mandatory parameter.
name: the VM name
memory: the amount of memory to dedicate to the VM
root_disk_size: the size of the root disk in GB
vcpus: the number of vcpu to dedicate to the VM
root_password: the root password in clear text
groups: this list of groups will be used if you generate an Ansible inventory.
networks: a list of network to attach to the VM. The default is: one virtio interface attached to
network: the name of the network. Default is the key
network_namefrom the configuration (
ipv4: a static IPv4. Default is a dynamic IPv4 address.
nic_model: the libvirt driver to use. Default is
- name: esxi-vcenter distro: esxi-6.7 memory: 12000 root_disk_size: 30 vcpus: 2 root_password: '!234AaAa56' groups: ['all_esxi'] - name: esxi1 distro: esxi-6.7 memory: 4096 vcpus: 1 root_password: '!234AaAa56' groups: ['all_esxi', 'esxi_lab'] - name: esxi2 distro: esxi-6.7 memory: 4096 vcpus: 1 root_password: '!234AaAa56' groups: ['all_esxi', 'esxi_lab'] - name: centos-7 distro: centos-7 networks: - network: default ipv4: 192.168.122.50 bootcmd: - yum update -y
cat /var/lib/virt-lightning/pool/upstream/esxi-6.7.yaml username: root python_interpreter: /bin/python memory: 4096 networks: - network: virt-lightning nic_model: virtio - network: default nic_model: e1000