Molecule
A testing framework for Ansible roles that creates a disposable test machine, applies the role, checks the result and destroys the machine.
In more detail
Tests are organised as scenarios, each with a driver that chooses where the test machine runs, such as a container or a virtual machine. Molecule exercises the role against a real target, which catches problems syntax checks and linting cannot. Its evidence is limited to the platforms and driver you chose, so state those limits in the test report.
Related terms
- Molecule scenario — A named Molecule test setup, configured in molecule/<name>/molecule.yml, that fixes the driver, platforms, provisioner and verifier for one test run.
- Molecule driver — The Molecule setting that decides where test instances run, such as containers, virtual machines or an existing machine.
- converge — To bring a machine to the described state; in Molecule, the phase that applies the role to the test instance.
- verifier — The Molecule setting and phase that checks the converged test instance really shows the results the role promises.
- Ansible role — A reusable package of tasks, handlers, templates, files and variables for one unit of automation, laid out in a standard directory structure.
Taught in
- Ansible Galaxy — Ansible Configuration Management at Scale
- Testing With Molecule — Ansible Configuration Management at Scale