Overview
The@local connector runs commands on your local machine instead of connecting to remote hosts via SSH.
The local connector is only compatible with macOS and Linux hosts. Windows is not supported.
Basic Usage
CLI Examples
Inventory
Example Deploy
Here’s a complete example managing the local machine:Use Cases
Local Development Setup
Bootstrap a development environment:CI/CD Pipelines
Use in CI/CD to configure the build agent:Testing Operations
Test operations locally before deploying remotely:Combining Local and Remote Hosts
You can mix local and remote hosts in the same inventory:Privilege Escalation
Use sudo for operations requiring elevated privileges:API Usage
Use the local connector in API mode:Command Execution
The local connector uses subprocess to execute commands:Environment Variables
Pass environment variables to local commands:Timeout
Set command timeouts:Limitations
Security Considerations
Comparison with Other Connectors
Source Reference
Location:src/pyinfra/connectors/local.py:26
Key Properties
handles_execution- This connector handles command execution directly
Key Methods
run_shell_command()- Execute command locally (line 50)put_file()- Copy file locally (line 107)get_file()- Copy file locally (line 132)
