ansible-testinfra

Bootstrap a pytest and Testinfra suite for Ansible role validation.

Updated Nov 12, 2025
One-click install
npx skills add https://github.com/jphetphoumy/skillstack --skill ansible-testinfra
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ansible-testinfra
Source: https://github.com/jphetphoumy/skillstack/tree/main/skills/ansible-testinfra
Command: npx skills add https://github.com/jphetphoumy/skillstack --skill ansible-testinfra

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill bootstraps a minimal Testinfra-based test suite for an Ansible role, providing a ready-to-run starting point for infrastructure validation.

Core Features & Use Cases

  • Project bootstrap: Creates tests/ and pyproject.toml with Pytest/Testinfra dependencies.
  • Starter tests: Provides a basic test_<role>.py that checks package, service, and port.
  • Guided run: Reminds you to run tests with uv run pytest after setup.

Quick Start

  1. Create your role and place tests under tests/<role>.
  2. Run: uv run pytest --hosts ssh://<host>
  3. Extend tests as needed.

Frequently Asked Questions about ansible-testinfra

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test an Ansible role with Testinfra?

Testinfra validates infrastructure by writing pytest tests that check packages, services, ports, and other system state on remote hosts. This Skill bootstraps a minimal pytest + testinfra suite with a test directory, pyproject.toml, and starter test file ready to run against your Ansible role.

What do I need to set up before writing Testinfra tests for Ansible?

You need Python 3.10+, an Ansible role, and pytest with the testinfra plugin installed. This Skill creates the project structure and dependency configuration (pyproject.toml) so you can immediately run tests via uv run pytest against your infrastructure.

Can I use Testinfra to validate infrastructure after Ansible deployment?

Yes. Testinfra runs pytest tests against live systems over SSH to verify packages, services, ports, and configuration are correct after Ansible applies changes. This Skill generates a ready-to-run test suite that connects to your target hosts and validates the deployment.

How do I run Testinfra tests against a remote host?

Execute uv run pytest --hosts ssh://<host> to run your test suite against a remote system. This Skill provides the starter tests and project configuration; you specify the SSH host URI and the tests execute validation checks on that infrastructure.

What does a basic Testinfra test check?

A starter Testinfra test verifies that required packages are installed, a service is running, and it listens on the expected port. This Skill generates a template test_<role>.py that checks these common validation points; you extend it with additional assertions as needed.

Do I need to understand pytest to use Testinfra with Ansible?

Basic pytest knowledge is helpful but not required. This Skill generates a starter test file with pytest + testinfra patterns already in place, and provides reminders on how to execute tests, so you can begin validating infrastructure immediately and learn patterns from the generated code.