pyinfra turns Python functions into idempotent shell operations on SSH hosts, local machines, or Docker targets. Inventories and deploy scripts run concurrently at scale.
Overview
pyinfra is a Python-native alternative to YAML-driven configuration management. Users define operations such as package installs, file templates, and service reloads in plain Python modules, then execute them against inventories of hosts.
The CLI streams realtime stdout and stderr, supports dry runs with diffs, and targets connectors including SSH, local shell, Docker, Terraform, and Vagrant. It advertises agentless execution because remote systems only need SSH and a shell.
Typical workflows pair an inventory.py host list with a deploy.py operations file. Global arguments control limits, verbosity, and concurrency through gevent-backed parallel SSH.
Documentation and examples cover quickstart usage, operation libraries, and integration with the broader Python packaging ecosystem via uv or pip installs.
Key features
- Python declarative operations
- Concurrent SSH execution
- Idempotent diff and dry-run mode
- Docker and local connectors
- Terraform and Vagrant integrations
- Realtime verbose logging
- Inventory as Python data
- No remote agents required
Use cases
- Server provisioning and deploys
- Ad-hoc fleet commands
- Container configuration
- Replacing Ansible-style workflows