explaingit

pyinfra-dev/pyinfra

5,644PythonAudience · ops devopsComplexity · 3/5Setup · moderate

TLDR

A Python tool that automates server setup by running shell commands over SSH. Write Python scripts describing what your servers should look like, and pyinfra applies the changes.

Mindmap

mindmap
  root((pyinfra))
    What it does
      Server automation
      SSH command execution
      Declarative operations
    Targets
      SSH servers
      Local machine
      Docker containers
    Workflow modes
      Ad-hoc commands
      Declarative state files
    Audience
      DevOps engineers
      Sysadmins
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Automate software installation and configuration across a fleet of Linux servers without installing agent software.

USE CASE 2

Run the same shell command on dozens of servers at once from your local machine.

USE CASE 3

Write Python scripts that keep your servers or Docker containers in a consistent, repeatable state.

Tech stack

PythonSSHDocker

Getting it running

Difficulty · moderate Time to first run · 30min

Requires SSH access to target servers and Python on your local machine.

No license information is available from the sources provided.

In plain English

Pyinfra is a Python tool for automating server configuration and deployment tasks. Instead of writing configuration files in a special format or learning a new language, you write plain Python scripts that describe what your servers should look like. Pyinfra then translates those Python instructions into the actual shell commands needed to make each server match your specifications. The tool connects to servers over SSH by default, so you do not need to install any agent software on the machines you are managing. It also works on your local machine and inside Docker containers, which makes it possible to test infrastructure changes in a safe environment before applying them to production servers. Pyinfra supports two main workflows. In the first, you can run ad-hoc commands across many servers at once, similar to running a shell command on one machine but doing it on dozens or hundreds at the same time. In the second, you write declarative operation files that describe the desired state of your servers: which packages should be installed, which files should exist, which services should be running. Pyinfra figures out the steps needed to reach that state and runs them. The project is described as high performance and built to scale from a single server up to thousands. Because it uses Python, you can bring in the full Python ecosystem to add logic to your infrastructure code, such as loops, conditionals, reading configuration from files, or connecting to external APIs. No README is included in the repository root, so this description is based on the project metadata. The official documentation and usage examples live on the project's external documentation site.

Copy-paste prompts

Prompt 1
I have 20 Ubuntu servers and I want to install nginx and deploy a config file on all of them using pyinfra. Write me a deploy.py script that does this over SSH.
Prompt 2
Help me write a pyinfra operation that checks if a service is running on a remote server and starts it if not.
Prompt 3
I want to use pyinfra to manage a local Docker container for testing. Write me a script that installs a package inside the container using pyinfra's Docker connector.
Open on GitHub → Explain another repo

← pyinfra-dev on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.