No description
  • Python 95.4%
  • Jinja 4.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
oliver.maklott b4454caa06
All checks were successful
ci / build (push) Successful in 1s
ci / units (push) Successful in 3s
ci / lint (push) Successful in 7s
ci / sanity (push) Successful in 9s
ci / molecule (push) Successful in 1m53s
release / release (push) Successful in 2s
belowtoxic.testing 0.3.0: guest_ssh_port
qemu_vm and qemu_lab take the port sshd listens on inside the guest
(default 22), for guests whose first-boot configuration moves it - the
site repository's anchor and identity scenarios run sshd on another port.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PVUe4g65L7UnUVqHmQp7kG
2026-11-29 09:11:18 +00:00
.forgejo/workflows belowtoxic.testing 0.1.1: accept degraded cloud-init first boots 2026-11-22 20:47:07 +00:00
changelogs belowtoxic.testing 0.3.0: guest_ssh_port 2026-11-29 09:11:18 +00:00
extensions/molecule belowtoxic.testing 0.1.1: accept degraded cloud-init first boots 2026-11-22 20:47:07 +00:00
meta belowtoxic.testing 0.1.0: unprivileged QEMU lab for Molecule 2026-11-22 20:04:15 +00:00
plugins belowtoxic.testing 0.3.0: guest_ssh_port 2026-11-29 09:11:18 +00:00
roles/qemu_lab belowtoxic.testing 0.3.0: guest_ssh_port 2026-11-29 09:11:18 +00:00
tests/unit/plugins belowtoxic.testing 0.3.0: guest_ssh_port 2026-11-29 09:11:18 +00:00
.ansible-lint belowtoxic.testing 0.1.0: unprivileged QEMU lab for Molecule 2026-11-22 20:04:15 +00:00
.copier-answers.yml belowtoxic.testing 0.1.1: accept degraded cloud-init first boots 2026-11-22 20:47:07 +00:00
.gitignore belowtoxic.testing 0.1.0: unprivileged QEMU lab for Molecule 2026-11-22 20:04:15 +00:00
.gitleaks.toml belowtoxic.testing 0.1.0: unprivileged QEMU lab for Molecule 2026-11-22 20:04:15 +00:00
.pre-commit-config.yaml belowtoxic.testing 0.1.0: unprivileged QEMU lab for Molecule 2026-11-22 20:04:15 +00:00
.yamllint belowtoxic.testing 0.1.0: unprivileged QEMU lab for Molecule 2026-11-22 20:04:15 +00:00
CHANGELOG.md belowtoxic.testing 0.3.0: guest_ssh_port 2026-11-29 09:11:18 +00:00
CONTRIBUTING.md belowtoxic.testing 0.1.0: unprivileged QEMU lab for Molecule 2026-11-22 20:04:15 +00:00
galaxy.yml belowtoxic.testing 0.3.0: guest_ssh_port 2026-11-29 09:11:18 +00:00
LICENSE belowtoxic.testing 0.1.0: unprivileged QEMU lab for Molecule 2026-11-22 20:04:15 +00:00
README.md belowtoxic.testing 0.1.1: accept degraded cloud-init first boots 2026-11-22 20:47:07 +00:00
ruff.toml belowtoxic.testing 0.1.0: unprivileged QEMU lab for Molecule 2026-11-22 20:04:15 +00:00
SECURITY.md belowtoxic.testing 0.1.0: unprivileged QEMU lab for Molecule 2026-11-22 20:04:15 +00:00

belowtoxic.testing

Unprivileged QEMU lab for Molecule: boots Debian, Ubuntu and Flatcar VMs as an ordinary user, wires them into multi-VM topologies with point-to-point links, and hands them to Molecule. No libvirt, no bridges, no root.

Part of belowtoxic-ansible.

Content

Name Type Purpose
belowtoxic.testing.qemu_lab role tasks_from: create / destroy for Molecule's managed driver
belowtoxic.testing.qemu_vm module Start/stop one QEMU VM (slirp management NIC with SSH forward, UDP links, cloud-init seed, fw_cfg)
belowtoxic.testing.free_ports module Free TCP+UDP ports on 127.0.0.1
belowtoxic.testing.lab_links filter Wire link names of Molecule platforms to UDP port pairs
belowtoxic.testing.lab_mac filter Deterministic MAC of a lab VM's NIC

How a lab looks

          controller (127.0.0.1)
        ssh :p1 │            │ ssh :p2          management: QEMU user networking
         ┌──────┴───┐   ┌────┴─────┐            (DHCP, NAT, SSH port forward)
         │ upstream │───│    hv    │            links: UDP socket pairs on 127.0.0.1,
         └──────────┘ ↑ └──────────┘            one virtio NIC per link, no DHCP
                    link "uplink"
  • Images are downloaded once per machine into ~/.cache/belowtoxic-testing/images and verified against the distribution's checksum list (Debian SHA512SUMS, Ubuntu SHA256SUMS, Flatcar .DIGESTS).
  • Debian/Ubuntu get a cloud-init NoCloud seed (user ansible, passwordless sudo; the management NIC is renamed mgmt0 where the distribution allows it at first boot - Ubuntu 26.04 keeps its predictable name). Flatcar gets an Ignition config via fw_cfg (user core).
  • Every NIC has a deterministic MAC (lab_mac), so tests find interfaces by MAC; the inventory gets qemu_lab_macs: {mgmt: ..., <link>: ...} per host.
  • KVM is used when /dev/kvm is usable, otherwise QEMU falls back to TCG emulation (slow, but works).

Using it in a scenario

requirements.yml of the collection under test (or extensions/molecule/requirements.yml):

collections:
  - name: https://git.belowtoxic.cloud/belowtoxic-ansible/collection-testing.git
    type: git
    version: v0.1.0

molecule.yml:

driver:
  name: default
  options:
    managed: true
platforms:
  - name: upstream
    image: debian-13          # debian-13, ubuntu-24.04, ubuntu-26.04, flatcar-stable
    links: [uplink]
  - name: hv
    image: debian-13
    memory: 2048
    cpus: 2
    links: [uplink]
    groups: [hypervisors]
    cloud_init:               # merged into the generated cloud-config
      packages: [nftables]
provisioner:
  name: ansible
  playbooks:
    create: ../shared/create.yml
    destroy: ../shared/destroy.yml

shared/create.yml (and destroy.yml with tasks_from: destroy):

- name: Create lab
  hosts: localhost
  gather_facts: false
  tasks:
    - name: Create QEMU lab VMs
      ansible.builtin.include_role:
        name: belowtoxic.testing.qemu_lab
        tasks_from: create
      vars:
        qemu_lab_platforms: "{{ molecule_yml.platforms }}"

Flatcar platforms accept ignition: - an Ignition config (dict) merged into the generated one. Flatcar has no Python: use ansible.builtin.raw in verify.yml.

See roles/qemu_lab/README.md for all variables, and extensions/molecule/ for working examples (two linked VMs; Flatcar).

Host requirements

qemu-system-x86_64, qemu-img, xorriso, ssh, and ideally read/write access to /dev/kvm (user in group kvm). In CI, bt-ci molecule runs the scenarios inside the toolchain container (with /dev/kvm passed through) when the host lacks these but has docker.

Development

eval "$(../toolchain/bin/bt-ci-setup)"
bt-ci lint && bt-ci sanity && bt-ci units
bt-ci molecule default      # two linked VMs, ~3 min with KVM
bt-ci molecule flatcar      # Flatcar via Ignition

License

GPL-3.0-or-later, see LICENSE.