PyInfra 3.8.0, the latest release of the Python-based infrastructure automation framework, is now available. The update brings significant performance improvements through better parallelization of SSH connections and optimized task queue management, along with a revamped connection pooling system. The release also adds support for Windows and macOS platforms, and the project has switched to full semantic versioning (semver) starting with this 3.8.0 release.
Core improvements
The core API has been decoupled from Click by introducing pluggable output functions, making PyInfra more flexible for integration into different workflows. A notable security fix addresses command injection by expanding quoting of user inputs across connectors, operations, and utility functions. The FunctionCommand now supports timeouts, and a new config.INHERIT_ENV option allows passing local process environment variables to all operations.
New facts and operations
This release adds a substantial number of new facts and operations:
- Facts:
Ports(listening ports),AuthorizedKeys,GpgKeyrings,server.Processes, Docker version/container/image/network details, andrequires_commandguard sentinel withcheck_preconditions()hook. - Operations:
files.unarchive,files.downloadwith bandwidth capping vialimit_rate,server.kill,gpg.*operations, Docker login/logout, Docker compose, Docker build, andapt.packageswith a purge option. - Git:
git.reponow supports thedepthparameter for shallow clones. - Mount: Fixed detection of already-mounted devices in
server.mount. - SELinux: Fixed
selinux.portoperation to find existing labels when thesepolicycommand is missing. - Systemd: User-mode systemd facts no longer fail if the user manager is unavailable.
- Crontab: Full
crontab(5)environment variable syntax is now matched. - ZFS: Returns an empty dict if
zfs/zpoolcommands are not available. - Apt: Modernized
apt.keyto replace the deprecatedapt-keycommand, and added deb822 format support forAptSources.
Connector and platform updates
SSH connectors now properly parse SSH config file comments and honor ConnectTimeout through ProxyJump. The IdentityAgent config directive is now supported. For macOS and Python 3.13 compatibility, connectors use gevent.subprocess in utilities. Askpass generation errors are now shown to the user.