Registry / testing / tox-ansible

tox-ansible

JSON →
library26.6.0pypypiunverified

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.

pip install tox-ansible
INSTALL
IMPORT
SIG · TOX-ANSIBLE
T
tox-ansible
testingpythonv26.6.0
Install
6.6s avg
Import
Disk
79MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v26.6.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 84.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 6.6s · import 0.000s · 86MB
79MB installed
● package 79MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tox-ansible (plugin)
tox is invoked from the command line; tox-ansible is loaded as a plugin automatically.
tox-ansible is a tox plugin and is not typically imported directly in Python code. Its functionality is exposed via the 'tox' command-line interface.

To get started, create an empty `tox-ansible.ini` file in the root of your Ansible collection. Then, list the dynamically generated Ansible testing environments using `tox list --ansible --conf tox-ansible.ini`. To run tests in a specific environment, like `sanity-py3.11-2.14`, execute `tox -e sanity-py3.11-2.14 --ansible --conf tox-ansible.ini`. You can also run all tests of a specific type (e.g., `unit`) across all available environments using `tox -f unit --ansible -p auto --conf tox-ansible.ini`.

touch tox-ansible.ini tox list --ansible --conf tox-ansible.ini tox -e sanity-py3.11-2.14 --ansible --conf tox-ansible.ini
Debug
Known issues
gotchaThe documentation for tox-ansible has been noted as vague and difficult to follow, often leading to assumptions and guesswork when configuring tests.
fix
Consult community resources and GitHub issues for clarification. Experiment with configurations carefully and incrementally.
affects: All versions
gotchaUsers have reported difficulties running pytest unit tests successfully without explicitly setting the PYTHONPATH to include the collection path.
fix
Ensure that your testing environment's PYTHONPATH correctly includes the path to your Ansible collection, or investigate specific pytest-ansible configurations.
affects: All versions
gotchaOverriding default tox-ansible configurations for integration tests might introduce fragility, potentially breaking when the underlying matrix of Python and Ansible versions changes.
fix
Minimize overrides where possible. If custom configurations are necessary, thoroughly test them against new Python and Ansible versions, especially when upgrading dependencies.
affects: All versions
gotchaAvoid 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.
fix
Use generic environment names like `py` for unit tests and rely on tox-ansible's dynamic environment generation for version matrix testing. For CI/CD, ensure the base Python interpreter is consistent or explicitly defined outside the tox `envlist`.
affects: All versions
gotchaWhen 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.
fix
For integration tests requiring specific environments, consider using custom Docker images or more explicit environment definitions to ensure stability across container updates.
affects: All versions
Upgrade
Version history
26.6.0latest on PyPI · released Jun 12, 2026
Audit
Dependencies
toxrequiredCore testing framework, tox-ansible is a plugin for it.
pytest-ansiblerequiredProvides pytest integration for Ansible content.
pytestrequiredUsed for unit and integration tests.
pytest-xdistrequiredUsed for parallel test execution.
pyyamlrequiredYAML parsing for configuration and Ansible content.
ansible-dev-environmentrequiredHandles collection installation, ansible-core versioning, and Python dependency resolution within test environments.
Agent activity
14 hits · last 30 days
node
10
Resources
tox-ansible — pip install tox-ansible · libregistry