pyinfra.api.facts module

The pyinfra facts API. Facts enable pyinfra to collect remote server state which is used to “diff” with the desired state, producing the final commands required for a deploy.

Note that the facts API does not use the global currently in context host so it’s possible to call facts on hosts out of context (ie give me the IP of this other host B while I operate on this host A).

class pyinfra.api.facts.FactBase

Bases: Generic[T]

abstract: bool = True
command: Callable[[...], str | StringCommand]
static default() T

Set the default attribute to be a type (eg list/dict).

name: str
process(output: Iterable[str]) T
process_pipeline(args, output)
requires_command(*args, **kwargs) str | None
shell_executable: str | None = None
class pyinfra.api.facts.ShortFactBase

Bases: Generic[T]

fact: Type[FactBase]
name: str
pyinfra.api.facts.get_fact(state: State, host: Host, cls: type[FactBase], args: Any | None = None, kwargs: Any | None = None, ensure_hosts: Any | None = None, apply_failed_hosts: bool = True) Any
pyinfra.api.facts.get_facts(state: State, *args, **kwargs)
pyinfra.api.facts.get_host_fact(state: State, host: Host, cls, args: Iterable | None = None, kwargs: dict | None = None) Any
pyinfra.api.facts.get_short_facts(state: State, host: Host, short_fact, **kwargs)