pyinfra
pyinfra automates/provisions/manages/deploys infrastructure.
What it is and what it does
pyinfra is a Python-based infrastructure automation tool that converts Python code into shell commands and executes them on remote servers, Docker containers, or the local machine. Unlike YAML-based tools, it lets you write provisioning logic in Python with full access to the language's ecosystem. It operates agentlessly over SSH or other connectors, meaning no daemon needs to run on target systems.
You define infrastructure state through declarative operations (e.g., installing packages, managing files, running commands) and organize targets in an inventory. pyinfra supports idempotent operations, dry runs, and diffs before changes take effect. It scales from single-server deployments to thousands of hosts and integrates with Docker, Terraform, and Vagrant.
Use it for:
- Provision and configure multiple servers in parallel using Python instead of YAML or shell scripts.
- Deploy applications with idempotent operations that can be safely re-run without side effects.
- Automate Docker container setup and configuration as part of a larger deployment pipeline.
- Write infrastructure code that leverages Python libraries and logic for complex conditional deployments.
- Perform ad-hoc commands and debugging across many servers with real-time output visibility.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
pyinfra executes Python code as infrastructure automation, translating declarative operations into shell commands and running them over SSH, Docker, or local targets at scale.
Yes. pyinfra is actively maintained, has no known vulnerabilities, and offers a low-friction install. It's well-suited if you prefer Python over YAML for infrastructure automation and need agentless execution over SSH or containers. The 11 dependencies are standard and widely used. Consider it if your team is already Python-fluent and wants to avoid learning a separate DSL.
Install
pyinfra on PyPI
pip
pip install pyinfrauv
uv add pyinfrapoetry
poetry add pyinfraInstalling pyinfra
Before you install
Low friction install with a pure-Python wheel. Active maintenance with a recent release (18 days old) and sustained development since 2015. Supports Python 3.10–3.14.
License in practice
MIT license permits commercial and private use with minimal restrictions; safe for most deployment contexts.
Quickstart
pip install pyinfra
from pyinfra.operations import apt
apt.packages(
name="Ensure iftop is installed",
packages=['iftop'],
update=True,
_sudo=True,
)
Requires SSH access to target servers or Docker daemon for container targets; operations execute as the connected user.
Verify before relying
- Whether the 11 runtime dependencies (gevent, paramiko, pydantic, etc.) introduce any transitive security concerns not captured in OSV.
- Performance characteristics and scaling limits when targeting thousands of hosts simultaneously.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 11 — click, distro, gevent, jinja2, packaging, paramiko, pydantic, python-dateutil, typeguard, types-paramiko, typing-extensions |
| Maintenance | actively maintained — 18 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 290,475/month — #7,987 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pyinfra-3.10.0-py3-none-any.whl
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
spurProvides a unified Python interface to run…
permissive · top 15,000 on PyPI
ansibleAnsible is an IT automation system that handles…
copyleft · top 5,000 on PyPI
ansible-runnerAnsible Runner provides a Python library and…
permissive · top 5,000 on PyPI
ansible-baseAnsible-base is the core automation engine for…
copyleft · top 15,000 on PyPI
parallel-sshAsynchronous SSH client for running commands on…
copyleft · top 15,000 on PyPI
falfal is a serverless Python runtime that…
unclear · top 15,000 on PyPI
ansible-coreAnsible Core is the engine for agentless IT…
copyleft · top 5,000 on PyPI
fabricFabric executes shell commands remotely over…
permissive · top 5,000 on PyPI
fabric2Fabric executes shell commands remotely over…
permissive · top 15,000 on PyPI
nornirNornir is a pure Python automation framework…
permissive · top 15,000 on PyPI