Facts IndexΒΆ
pyinfra
uses facts to determine the existing state of a remote server. Operations use this information to generate commands which alter the state. Facts are read-only and is populated at the beginning of the deploy.
Facts can be executed/tested via the command line:
# Example how to get multiple facts from a server myhost.com
pyinfra myhost.com fact server.Date server.Hostname ...
If you want to pass an argument to a fact, pass it with key=value
. For example:
# See if the package 'openssh-server' is installed servers myhost.com and myhost2.com
pyinfra myhost.com,myhost2.com fact deb.DebPackage name=openssh-server
Multiple facts with arguments may be called like so:
pyinfra @local fact files.File path=setup.py files.File path=anotherfile.txt
You can leverage facts as part of within operations like this:
from pyinfra import host
from pyinfra.facts.server import LinuxName
if host.get_fact(LinuxName) == 'Ubuntu':
apt.packages(...)
Want a new fact? Check out the writing facts guide.
Facts, like operations, are namespaced as different modules - shortcuts to each of these can be found in the sidebar.
- Apk Facts
- Apt Facts
- Brew Facts
- Bsdinit Facts
- Cargo Facts
- Choco Facts
- Deb Facts
- Dnf Facts
- Docker Facts
- Files Facts
- Gem Facts
- Git Facts
- Gpg Facts
- Hardware Facts
- Iptables Facts
- Launchd Facts
- Lxd Facts
- Mysql Facts
- Npm Facts
- Openrc Facts
- Pacman Facts
- Pip Facts
- Pkg Facts
- Pkgin Facts
- Postgresql Facts
- Rpm Facts
- Selinux Facts
- Server Facts
server.Arch
server.Command
server.Crontab
server.Date
server.Groups
server.HasGui
server.Home
server.Hostname
server.Kernel
server.KernelModules
server.KernelVersion
server.LinuxDistribution
server.LinuxGui
server.LinuxName
server.Locales
server.LsbRelease
server.MacosVersion
server.Mounts
server.Os
server.OsVersion
server.Path
server.SecurityLimits
server.Selinux
server.Sysctl
server.User
server.Users
server.Which
- Snap Facts
- Systemd Facts
- Sysvinit Facts
- Upstart Facts
- Vzctl Facts
- Windows Facts
windows.Aliases
windows.Bios
windows.ComputerInfo
windows.Date
windows.Home
windows.Hostname
windows.Hotfixes
windows.InstallerApplications
windows.LastReboot
windows.LocalDrivesInfo
windows.LocalGroups
windows.LoggedInUserInfo
windows.LogonSessionInfo
windows.NetworkConfiguration
windows.Os
windows.OsVersion
windows.Processes
windows.Processors
windows.Service
windows.Services
windows.SystemType
windows.Where
- Windows_Files Facts
- Xbps Facts
- Yum Facts
- Zypper Facts