Molecule aids in the development and testing of Ansible roles
—
The Molecule core API provides access to the plugin system and runtime configuration, enabling developers to extend Molecule with custom drivers and verifiers while providing programmatic access to available plugins.
Functions for discovering and accessing available drivers and verifiers in the Molecule plugin ecosystem.
def drivers(config=None):
"""
Return list of active drivers.
Args:
config (Config|None): plugin config
Returns:
dict[str, Driver]: A dictionary of active drivers by name
"""
def verifiers(config=None):
"""
Return list of active verifiers.
Args:
config (Config|None): plugin config
Returns:
dict[str, Verifier]: A dictionary of active verifiers by name
"""Access to package version information for compatibility checking and reporting.
__version__: str # Package version string
version: str # Version information (alias for __version__)Warning classes for handling runtime issues and compatibility problems.
class MoleculeRuntimeWarning(RuntimeWarning):
"""A runtime warning used by Molecule and its plugins."""
class IncompatibleMoleculeRuntimeWarning(MoleculeRuntimeWarning):
"""A warning noting an unsupported runtime environment."""from molecule.api import drivers, verifiers
# Get all available drivers
available_drivers = drivers()
for name, driver in available_drivers.items():
print(f"Driver: {name}")
print(f" Version: {driver.version}")
print(f" Module: {driver.module}")
if driver.required_collections:
print(f" Required collections: {driver.required_collections}")
# Get all available verifiers
available_verifiers = verifiers()
for name, verifier in available_verifiers.items():
print(f"Verifier: {name}")
print(f" Enabled: {verifier.enabled}")import molecule
# Check version compatibility
current_version = molecule.__version__
print(f"Running Molecule version: {current_version}")
# Version is also available as 'version'
assert molecule.version == molecule.__version__from molecule.config import Config
from molecule.api import drivers, verifiers
# Create a config instance
config = Config()
# Get plugins with configuration
configured_drivers = drivers(config)
configured_verifiers = verifiers(config)drivers() and verifiers() functions use setuptools entry points to discover plugins@cache decoratorInstall with Tessl CLI
npx tessl i tessl/pypi-molecule