A GitHub Action that runs commands on remote servers over SSH from your CI/CD workflows.
pyinfra-dev/pyinfra
An infrastructure automation tool that runs Python-defined operations and shell commands on SSH servers, local machines and Docker containers.
Open-source alternative to:Ansible
- Stars
- 6,044
- Forks
- 558
- Open issues
- 166
- Last commit
- 7 days ago
What is it?
pyinfra is an infrastructure automation tool that lets you write server configuration and deployment logic in Python rather than YAML. You can run one-off shell commands across many hosts, or define declarative operations such as installing packages or managing files, which pyinfra turns into shell commands and executes on the targets.
Targets can be remote servers reached over SSH, the local machine, or Docker containers. Operations are idempotent, so you can preview changes with diffs and dry runs before applying them. Real-time stdin, stdout and stderr output is available for debugging with increasing verbosity flags.
Because it is ordinary Python, you can use the wider Python package ecosystem inside your deployment scripts. The project is agentless, requiring only shell access on the target, and it includes connectors for Docker, Terraform and Vagrant.
Key features
- 01Write deployment logic as Python code instead of YAML.
- 02Run ad-hoc commands or declarative operations across SSH hosts, the local machine and Docker containers.
- 03Idempotent operations support diffs and dry runs before changes are applied.
- 04Real-time command output helps debug failing steps.
- 05Agentless: only shell access on the target is required.
- 06Connectors for Docker, Terraform and Vagrant inventories.
Use cases
- Configuring and deploying a fleet of servers from a single Python codebase.
- Running the same shell command across many hosts at once.
- Testing server setup in local Docker containers before touching production.
- Teams that want Ansible-style automation using Python instead of YAML.
Quick start
- 1
Install pyinfra with uv
uv tool install pyinfra - 2
Run a command on an SSH server
pyinfra my-server.net exec -- echo "hello world" - 3
Run a command in a Docker container
pyinfra @docker/ubuntu exec -- echo "Hello world"
Topics
FAQ
- What is pyinfra?
- An infrastructure automation tool that runs Python-defined operations and shell commands on SSH servers, local machines and Docker containers. pyinfra is an infrastructure automation tool that lets you write server configuration and deployment logic in Python rather than YAML. You can run one-off shell commands across many hosts, or define declarative operations such as installing packages or managing files, which pyinfra turns into shell commands and executes on the targets.
- Is pyinfra free to use? What license does it have?
- pyinfra is open source under the MIT license. Check the license terms before using it in commercial products.
- Is pyinfra still maintained?
- Actively maintained. The last commit to pyinfra was on Oct 15, 2026.
- What can I use pyinfra for?
- Configuring and deploying a fleet of servers from a single Python codebase. Running the same shell command across many hosts at once. Testing server setup in local Docker containers before touching production. Teams that want Ansible-style automation using Python instead of YAML.
- How do I install pyinfra?
- Install pyinfra with uv: uv tool install pyinfra Run a command on an SSH server: pyinfra my-server.net exec -- echo "hello world" Run a command in a Docker container: pyinfra @docker/ubuntu exec -- echo "Hello world"
- Where can I get pyinfra?
- The source code and installation instructions are on GitHub: https://github.com/pyinfra-dev/pyinfra
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
Infrastructure as code CLI that plans and applies declarative configuration files to create, change, and version cloud and service resources.
Official OVHcloud command-line interface for managing OVHcloud services, accounts and Public Cloud resources from the terminal.
A Python client library for Kubernetes with an API modeled on kubectl, offering sync and async (asyncio/trio) interfaces.
Shell-based runner for Clash / Mihomo proxy kernels on Linux, with subscription management, node selection, Tun mode and a built-in doctor command.
An open-source system to run, manage, and scale AI workloads across Kubernetes, Slurm, and 20+ clouds or GPU providers with one interface.