Skip to main content

libvirt Molecule Plugin :: run molecule tests on libvirt

Project description

PyPI Package Python Black Code Style Ansible Code of Conduct Ansible mailing lists Repository License

Molecule libvirt is designed to allow use of libvirt for provisioning test resources.

Please note that this driver is currently in its early stage of development, do not even try to install or use it until this message is removed.



pip install molecule-libvirt

Create a scenario

With a new role

molecule init role -d libvirt my-role

This will create a new folder my-role containing a bare-bone generated role like you would do with ansible-galaxy init command.

It will also contain a molecule folder with a default scenario using the libvirt driver (using ansible community.libvirt collection).

Install the collection using:

ansible-galaxy install -r test_requirements.yml.


This is a molecule.yml example file

name: galaxy
  name: libvirt
  - name: instance-1
    cpu: 1
    cpu_model: "qemu64"
    image_url: ""
    disk_size: "10G"
    ssh_port: 22
    memory_size: "1" # in GB
  - name: instance-2
    memory: "1"
    cpus: 1
    image_url: ""
    libvirt_host: "server.home.lan"
    libvirt_user: "james"
    bridge_name: "bridge0"
  - name: instance-3
    memory: "1"
    cpus: 1
    image_url: ""
    libvirt_host: "server.home.lan"
    libvirt_user: "james"
    bridge_name: "bridge0"
  name: ansible
  name: ansible

Optional parameters

molecule_bridge: existing bridge on local host. Can be useful if you want to set network interface name created for molecule. default value is: molecule-br0.

molecule_network_cidr: ip address range that should be bind to molecule virtual network. default value is:

qemu_user: qemu process user. On RHEL like system qemu user is qemu. On Debian like, qemu user is libvirt-qemu. default value is: qemu.

cpu_model: specifies CPU model requested by the guest virtual machine. default is : qemu64.

arch: specifying the CPU architecture to virtualization. default is x86_64.

timezone: vm’s timezone. default is America/Toronto.

bridge_name: existing bridge on remote host. This bridge should allow VM being reachable with an ip address.

libvirt_host and libvirt_user: remote host parameters. libvirt_user should belongs to libvirt group.

Once set, you will have to run:

molecule test


Read the documentation and more at

Get Involved


  • James Regis
  • Gaëtan Trellu
  • Gariele Cerami
  • Sorin Sbarnea


The MIT License.

The logo is licensed under the Creative Commons NoDerivatives 4.0 License.

If you have some other use in mind, contact us.

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

molecule-libvirt-0.0.5.tar.gz (24.0 kB view hashes)

Uploaded source

Built Distribution

molecule_libvirt-0.0.5-py3-none-any.whl (22.6 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page