1. Preparing the Environment
To avoid polluting the system Python, all the dependencies are installed in a virtual environment.
python3 -m venv .venv # create a virtual environment for Ansible/Molecule
source .venv/bin/activate # activate it
pip install --upgrade pip # upgrade pip
pip install ansible molecule molecule-plugins # install Ansible and Molecule
Check installation:
ansible --version
molecule --version
This repository provides a molecule_init.sh
script located in the bin
directory. To quickly activate the environment, source this script.
source bin/molecule_init.sh
1.1 Podman installation
Containerization makes testing much faster and easier because you do not need external dependencies. Not all tests can be performed in a container, but it’s a good starting point that will cover a large number of tests before executing the rest on real target systems. To run the tests in containers, you need to install a container manager. Podman is selected for execution under macOS.
brew install podman
Once Podman is installed, initialize and start the Podman machine, then check its status:
podman machine init
podman machine start
podman info