Molecule
Updated: September 28, 2024
Molecule is essentially a plugin for ansible used to test playbooks and roles.
Table of Contents
Commands
-d, --driver-name [delegated] # Name of driver to initialize. (delegated)
-r, --role-name TEXT # Name of the role to create.
--dependency-name [galaxy] # Name of dependency to initialize. (galaxy)
--lint-name [yamllint] # Name of lint to initialize. (ansible-lint)
--provisioner-name [ansible] # Name of provisioner to initialize. (ansible)
--verifier-name [ansible|testinfra] # Name of verifier to initialize. (ansible)
--help # Show this message and exit.
Usage
# create a new role with molecule
molecule init role acme.my_new_role --driver-name docker
# create molecule within a role that already exists
molecule init scenario -r role_name -d podman
Setup
Create a folder at
mkdir ~/python
In that folder install Python virtualenv for ubuntu or mac (brew)
sudo apt install python3-virtualenv
brew install virtualenv
Create moleculenv which makes a subdir with fresh install of python (inactive)
virtualenv molecule
Check which python is active
which python3
Activate virtual python env
source molecule/bin/activate
Deactivate virtual python env
deactivate
While active install packages
pip3 install "molecule[lint,ansible,podman]"