Linux command
pyinfra 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Deploy to servers
pyinfra [inventory] [deploy.py]
Run command on servers
pyinfra [inventory] exec -- [command]
Check what would change
pyinfra --dry [inventory] [deploy.py]
Deploy with facts
pyinfra [inventory] fact [server.Hostname]
说明
pyinfra automates infrastructure provisioning and configuration management using Python. Deploy scripts are written as regular Python files that describe desired system state through operations like installing packages, managing files, configuring services, and executing commands across groups of servers. The tool connects to targets over SSH without requiring agents on remote machines, making it lightweight to adopt. An inventory file defines target hosts and groups, while deploy scripts specify what operations to run. The --dry flag previews changes before applying them, and the fact command gathers system information from targets for conditional logic in deployments.
参数
- --dry
- Dry run mode; print operations without executing.
- --limit _HOSTS_
- Filter execution to specific hosts by name or glob pattern.
- --retry _N_
- Retry failed operations up to N times.
- --debug-inventory
- Print inventory hosts, groups, and data.
- --debug-facts
- Show facts after generating operations and exit.
- --debug-operations
- Show operations after generating and exit.
- exec
- Execute an arbitrary shell command on hosts.
- fact
- Gather facts from target hosts.
- -v, -vv, -vvv
- Increase verbosity (facts, shell input, shell output).
FAQ
What is the pyinfra command used for?
pyinfra automates infrastructure provisioning and configuration management using Python. Deploy scripts are written as regular Python files that describe desired system state through operations like installing packages, managing files, configuring services, and executing commands across groups of servers. The tool connects to targets over SSH without requiring agents on remote machines, making it lightweight to adopt. An inventory file defines target hosts and groups, while deploy scripts specify what operations to run. The --dry flag previews changes before applying them, and the fact command gathers system information from targets for conditional logic in deployments.
How do I run a basic pyinfra example?
Run `pyinfra [inventory] [deploy.py]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --dry do in pyinfra?
Dry run mode; print operations without executing.