Skip to main content
  1. Infrastructure/

pyinfra

Language: Python
License: MIT
Maturity: stable
Verified: 2026-02
Examples: Lab-in-a-Box (pyinfra-based lab deployment)

Overview #

pyinfra is an infrastructure automation tool that uses Python to define and execute deployments. It connects to target machines over SSH (or locally) and executes operations to install packages, configure services, manage files, and orchestrate multi-service deployments.

pyinfra occupies the same space as Ansible but uses Python directly instead of YAML. This makes deployment definitions testable, composable, and familiar to research teams that already work in Python.

Key Features #

  • Python-native – deployments are defined in .py files using a straightforward API
  • Agentless – connects over SSH, no agent installation on target machines
  • Fast – parallel execution across multiple hosts
  • Idempotent – operations check current state before making changes
  • Composable – deploy functions can be imported and reused across projects

git-annex / DataLad Integration #

Integration level: git-only.

pyinfra deployment configurations are Python files stored in a git repository. They do not interact with git-annex or DataLad directly, but the deployment code itself is version-controlled and auditable through standard git workflows.

The Lab-in-a-Box project uses pyinfra to deploy the entire con/serve infrastructure stack, with all deployment logic stored in a DataLad-tracked repository.

AI Readiness #

Level: ai-ready.

pyinfra configurations are Python source code – structured, readable, and well-suited for AI-assisted generation, review, and modification. LLMs can help write deployment recipes, review configurations for security issues, or generate new service definitions from natural language descriptions.

Role in the con/serve Stack #

pyinfra is the deployment engine behind Lab-in-a-Box. It automates the installation and configuration of Forgejo-Aneksajo, HedgeDoc, and other services that make up the self-hosted research infrastructure.

See Also #

  • Lab-in-a-Box – the pyinfra-based deployment that bundles all con/serve services
  • Forgejo-Aneksajo – primary service deployed by pyinfra
  • HedgeDoc – collaborative editor deployed by pyinfra