CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-molecule

Molecule aids in the development and testing of Ansible roles

Pending
Overview
Eval results
Files

core-api.mddocs/

Core API

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.

Capabilities

Plugin Discovery Functions

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
    """

Version Information

Access to package version information for compatibility checking and reporting.

__version__: str  # Package version string
version: str      # Version information (alias for __version__)

Runtime Warnings

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."""

Usage Examples

Discovering Available Plugins

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}")

Version Checking

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__

Plugin Configuration

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)

Integration Notes

  • The drivers() and verifiers() functions use setuptools entry points to discover plugins
  • Plugin loading failures are logged but don't make the entire tool unusable
  • The functions return OrderedDict instances for consistent plugin ordering
  • Plugin discovery is cached for performance using the @cache decorator

Install with Tessl CLI

npx tessl i tessl/pypi-molecule

docs

cli-commands.md

configuration.md

core-api.md

driver-system.md

exceptions.md

index.md

verifier-system.md

tile.json