pyinfra
$ pyinfra Official High Riskpyinfra automates ad-hoc commands and Python-based state deployments across SSH hosts, Docker containers, and local machines without remote agents. Unlike many provisioning tools, it combines native --dry diffing with --json output (which enforces non-interactive execution).
brew install pyinfra Direct SSH/Docker/local Python infrastructure runner with --dry --json; replaces multi-step remote SSH MCP tool calls.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
First-class --json output (automatically disabling interactive prompts) and --dry operation planning make headless automation clean.
- Native
--jsonoutput enforces non-interactive execution - Supports
factinspection anddebug-inventory --json
--dry inspects real host facts before calculating diffs, though deploy.py executes arbitrary Python and SSH commands with full remote-host blast radius.
- Accurate
--drydiffing via live fact gathering - Executes arbitrary Python and SSH commands on remote fleets
Distributed via Homebrew, pip, and uvx across macOS, Linux, and Windows (Python runtime required; SSH/Docker targets).
- Available via Homebrew,
pip, anduvx
Much faster than Ansible because it executes Python logic directly over persistent SSH/Paramiko connections with no remote agent.
- Agentless SSH/Docker/local execution with parallel fact gathering
Actively maintained open-source project (pyinfra-dev/pyinfra) under MIT.
- Active
pyinfra-dev/pyinfrarepo under MIT
Clean docs at docs.pyinfra.com detailing CLI flags, facts, and operations.
- Comprehensive CLI and API docs at docs.pyinfra.com
Security, Auth & Guardrails
Uses local SSH agent / ~/.ssh/ keys, Docker socket, or --sudo-password / env vars; no proprietary credential store.
MIT open-source and completely free.
# pyinfra Agent Rules - Always run `pyinfra <inventory> <deploy> --dry --json` before applying changes. - Remember `--json` enforces non-interactive mode; ensure SSH keys/agent are loaded first. - Never target production inventories with `exec` or `deploy.py` without explicit approval.
Agent-Ready Command Recipes
Safe Read-Only Queries
pyinfra inventory.py deploy.py --dry --json
Gathers facts from target hosts and computes proposed operations as JSON without executing any mutations.
pyinfra inventory.py fact server.LinuxName --json
Fetches OS metadata from inventory targets as structured JSON.
Controlled Writes & Previews
pyinfra @local exec -- 'uname -a'
Executes an ad-hoc shell command against @local using pyinfra's connector.
Strengths for Agents
- +
--dry --jsoncomputes exact diffs from live host facts without mutating targets. - +
--jsonautomatically enforces non-interactive execution. - + Works seamlessly across
@local,@docker, and SSH inventories with zero remote agents.
Caveats & Pitfalls
- ! Executing
deploy.pyruns arbitrary Python and remote SSH mutations if--dryis omitted. - ! Windows control-node support is secondary compared to macOS and Linux.