Molecule Docker Driver

2.1.0 · active · verified Thu Apr 16

Molecule Docker is a driver plugin for Molecule, the Ansible role testing framework. It allows users to test their Ansible roles against Docker containers, providing a lightweight and isolated environment for development and testing. The current version is 2.1.0, and it follows Molecule's release cadence, with major releases aligning with Molecule's major versions and frequent bugfix/minor updates.

Common errors

Warnings

Install

Quickstart

To quickly get started, create a `molecule/default/molecule.yml` file and a `molecule/default/converge.yml` file as shown. This configuration specifies the `docker` driver, uses a `pycontribs/centos:8` image, and runs a basic Ansible ping task. After saving these, navigate to the `molecule/default` directory and run `molecule test`.

# molecule/default/molecule.yml
---
dependency:
  name: galaxy
driver:
  name: docker
platforms:
  - name: instance
    image: "docker.io/pycontribs/centos:8"
    pre_build_image: true
provisioner:
  name: ansible
  playbooks:
    converge: converge.yml
verifier:
  name: ansible

# molecule/default/converge.yml
---
- name: Converge
  hosts: instance
  tasks:
    - name: "Check ping"
      ansible.builtin.ping

view raw JSON →