- Docker installed and running
- Python 3.11 (or Python 3.10)
- User must have Docker permissions
- Install Docker (if not already installed):
sudo apt-get install docker.io # Debian/Ubuntu
# or
sudo yum install docker # RHEL/CentOS- Start Docker and enable it:
sudo systemctl start docker
sudo systemctl enable docker- Add your user to the docker group:
sudo usermod -aG docker $USER
newgrp docker- Create a virtual environment and install tox:
python3 -m venv .venv
source .venv/bin/activate
pip install toxRun all test environments:
toxRun a specific test environment:
tox -e py311-ansible7Available test environments:
py310-ansible5,py310-ansible6,py310-ansible7py311-ansible5,py311-ansible6,py311-ansible7
You can customize the test environment:
# Use a different distro (default: ubuntu2004)
MOLECULE_DISTRO=ubuntu2204 tox
# Use a different playbook
MOLECULE_PLAYBOOK=custom.yml toxTo add or remove Python/Ansible versions, edit tox.ini:
Add a new version:
[tox]
envlist = py{310,311,312}-ansible{5,6,7,8} # Add py312 and ansible8Add dependencies for new Ansible version:
[testenv]
deps =
ansible5: ansible == 5.*
ansible6: ansible == 6.*
ansible7: ansible == 7.*
ansible8: ansible == 8.* # Add new versionRemove a version:
Simply remove it from the envlist (e.g., remove py310 or ansible5).
When you modify the HAProxy configuration template or add new features, update the test files:
- Update test variables in
molecule/default/inventory/group_vars/all.yml:
haproxy_config_peers:
mypeers:
peer:
- haproxy1 192.168.0.1:1024- Update expected output in
molecule/default/files/haproxy.cfg:
peers mypeers
peer haproxy1 192.168.0.1:1024
- Run tests to verify:
tox -e py311-ansible7