tox-ansible
tox-ansible is a utility designed to simplify the testing of Ansible content collections. Implemented as a tox plugin, it provides a streamlined way to test Ansible content across various Python interpreters and Ansible versions. It leverages tox for environment management, ansible-test sanity for sanity checks, and pytest for unit and integration tests. The current version is 26.3.0, and it follows a regular release cadence, often aligning with other Ansible development tools.
Warnings
- gotcha The documentation for tox-ansible has been noted as vague and difficult to follow, often leading to assumptions and guesswork when configuring tests.
- gotcha Users have reported difficulties running pytest unit tests successfully without explicitly setting the PYTHONPATH to include the collection path.
- gotcha Overriding default tox-ansible configurations for integration tests might introduce fragility, potentially breaking when the underlying matrix of Python and Ansible versions changes.
- gotcha Avoid using specific Python versions (e.g., `py39`) directly in the `envlist` for CI/CD pipelines. This can introduce bugs if the default Python version used for testing changes in the CI/CD environment.
- gotcha When running integration tests using `ansible-test` with default Docker containers, tests can unexpectedly fail due to updates in the base container (e.g., OS version changes), especially if your software has specific OS dependencies.
Install
-
pip install tox-ansible
Imports
- tox-ansible (plugin)
tox is invoked from the command line; tox-ansible is loaded as a plugin automatically.
Quickstart
touch tox-ansible.ini tox list --ansible --conf tox-ansible.ini tox -e sanity-py3.11-2.14 --ansible --conf tox-ansible.ini