--- id: pytest-ansible version: "26.8.0" license: MIT license_treatment: permissive maintenance: active --- # pytest-ansible — Plugin for pytest to simplify calling ansible modules from tests or fixtures License: permissive · Maintenance: active · Downloads: 983.4K/mo ## What it is and what it does pytest-ansible is a pytest plugin that bridges Ansible and pytest testing workflows. It was originally designed to let you call Ansible modules and iterate over inventory from inside test functions, eliminating the need for shell scripting. The plugin has been actively maintained since July 2014 and supports Python 3.10+ and ansible-core 2.14+. However, the maintainers have announced planned end-of-life in December 2026, as the broader ecosystem—including plain pytest, ansible-test, Molecule, tox-ansible, and ansible-dev-environment—now provides better-integrated solutions for collection testing and orchestration. The plugin remains functional and installable for existing users, but the documentation includes migration patterns using parametrize and subprocess helpers to replace its fixtures. If you are starting a new project, the migration paths in the documentation are the recommended approach. Use it for: - Run unit tests for Ansible collection modules using pytest with only Python 3.10+ and ansible-core installed. - Iterate over hosts and groups from an Ansible inventory within pytest parametrized tests without writing shell wrappers. - Execute ad-hoc Ansible module calls from pytest test functions to validate module behavior in isolation. - Integrate Ansible module testing into existing pytest CI pipelines for collections under active development. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. A pytest plugin that integrates Ansible into test functions, allowing you to call Ansible modules and iterate over inventory hosts directly from pytest tests. Yes, if you have an existing pytest-ansible codebase or need to test Ansible modules in pytest today—the plugin is stable and actively maintained. However, no for new projects: the maintainers recommend using plain pytest with parametrize and subprocess helpers (documented in the package), or Molecule for multi-host integration. Plan for migration before December 2026 EOL. ## Install pip install pytest-ansible uv add pytest-ansible poetry add pytest-ansible ## Installing pytest-ansible Before you install: Low friction install with a wheel distribution. Actively maintained as of August 2026, though the project is planned for end-of-life in December 2026; existing users should pin releases if long-term stability is required. License in practice: MIT license permits unrestricted use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects. Quickstart: pip install pytest-ansible # In tests/conftest.py or test file: import subprocess def test_ping(hostname: str) -> None: subprocess.run( ["ansible", "-i", "inventory", hostname, "-m", "ping"], check=True, ) Requires Python 3.10 or newer and ansible-core 2.14 or newer under active upstream support. Verify before relying: - Whether the deprecated status and December 2026 EOL timeline affects your project's long-term maintenance plans. - Whether existing pytest-ansible fixtures in your codebase are compatible with the recommended migration patterns (parametrize, subprocess helpers). ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 983.4K/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags ansible pytest plugin, test ansible modules with pytest, ansible inventory in tests, pytest ansible integration, run ansible from pytest, ansible collection unit testing, ansible-testing, deprecated-planned [View on SkillFed](https://skillfed.io/packages/pytest-ansible) · [View on PyPI](https://pypi.org/project/pytest-ansible/)