Molecule libvirt-ng Plugin
Molecule libvirt-ng is a Molecule driver for provisioning test VMs via libvirt/QEMU/KVM.
This is a modernized fork of the archived molecule-libvirt plugin, updated for current versions of Molecule and Ansible.
Requirements
Python >= 3.10
Molecule >= 24.2.0
Ansible >= 2.16
A working libvirt/QEMU/KVM setup on the host
libvirt-python (system package or built from source with pkg-config and libvirt headers)
virt-resize from guestfs-tools (for disk resizing)
Required Ansible collections (installed automatically via test_requirements.yml):
community.libvirt
community.crypto
community.general
ansible.posix
ansible.utils
Quickstart
Installation
pip install molecule-libvirt-ng
You also need libvirt-python which requires system libvirt headers:
# Debian/Ubuntu
sudo apt install libvirt-dev pkg-config python3-dev
# RHEL/Fedora
sudo dnf install libvirt-devel pkg-config python3-devel
pip install libvirt-python
Install the required Ansible collections:
ansible-galaxy collection install -r test_requirements.yml
Example
Create a molecule/default/molecule.yml in your Ansible role:
---
driver:
name: libvirt
platforms:
- name: debian12-test
image_url: "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2"
memory_size: 2
vcpu: 2
disk_size: "10G"
qemu_user: "qemu"
provisioner:
name: ansible
verifier:
name: ansible
Then run:
molecule test
Platform Parameters
Required
- image_url
URL to a cloud image (qcow2 format). Defaults to Debian 12 genericcloud.
Optional
- memory_size
RAM in GB. Default: 1.
- vcpu
Number of virtual CPUs. Default: 1.
- disk_size
Disk size (qemu-img format). Default: 15G.
- ssh_port
SSH port on the guest. Default: 22.
- cpu_model
CPU model requested by the guest. Default: qemu64.
- arch
CPU architecture. Default: x86_64.
- timezone
VM timezone. Default: America/Toronto.
- qemu_user
QEMU process user for filesystem ACLs. Varies by distro:
RHEL/Fedora: qemu (default)
Debian/Ubuntu: libvirt-qemu
NixOS: root
- image_volume
Partition to expand with virt-resize. Default: /dev/sda1.
- network_name
Use an existing libvirt network instead of creating a molecule-managed one.
- bridge_name
Use an existing bridge on a remote host. Makes the VM reachable via ARP.
- libvirt_host and libvirt_user
Provision VMs on a remote libvirt host via qemu+ssh://.
Network Parameters
These apply when molecule manages its own network (no network_name or bridge_name):
- molecule_bridge
Bridge interface name. Default: molecule-br0.
- molecule_network_cidr
IP range for the molecule network. Default: 10.10.10.0/24.
Documentation
Read the Molecule documentation at https://molecule.readthedocs.io/.
License
The MIT License.
Metadata
Release files for molecule-libvirt-ng 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| molecule_libvirt_ng-1.0.3.tar.gz | 20.1 kB | With provenance | Details for molecule_libvirt_ng-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| molecule_libvirt_ng-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for molecule_libvirt_ng-1.0.3-py3-none-any.whl |
Total release size: 41.3 kB
Release files / molecule_libvirt_ng-1.0.3.tar.gz
| Download URL | molecule_libvirt_ng-1.0.3.tar.gz |
|---|---|
| Size | 20.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
28ed2f027479d1338702f10365ff6026af21553fa658b3c565679a319c012276
|
|
BLAKE2b-256 checksum How to use checksums |
ce3943f52277f76bd369fe50757ab8616b26e2dc4775421732410ab148175dea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 16, 2026.
Transparency logRelease files / molecule_libvirt_ng-1.0.3-py3-none-any.whl
| Download URL | molecule_libvirt_ng-1.0.3-py3-none-any.whl |
|---|---|
| Size | 21.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c82d6a85e4f269fe6a03a338ca8f658803a5db928f4e8b3ca71e3e47d8c5a827
|
|
BLAKE2b-256 checksum How to use checksums |
ee9c146f346670bd250c79b7bd5bb2ade1bbdc4620bd740c2b74c7646c05b339
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 16, 2026.
Transparency logSecurity for molecule-libvirt-ng 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for molecule_libvirt_ng-1.0.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.