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: object

abstract: bool = True
command: str | Callable
static default()

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

name: str = 'pyinfra.api.facts.FactBase'
static process(output)
process_pipeline(args, output)
requires_command: str | None = None
shell_executable: str | None = None
class pyinfra.api.facts.FactNameMeta(name: str, bases, attrs, **kwargs)

Bases: type

class pyinfra.api.facts.ShortFactBase

Bases: object

fact: Type[FactBase]
name = 'pyinfra.api.facts.ShortFactBase'
static process_data(data)
pyinfra.api.facts.create_host_fact(state: State, host: Host, cls, data, args: List | None = None, kwargs: Dict | None = None)
pyinfra.api.facts.delete_host_fact(state: State, host: Host, cls, args: List | None = None, kwargs: Dict | None = None)
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, fact_hash: Any | None = None, use_cache: bool = True)
pyinfra.api.facts.get_facts(state: State, *args, **kwargs)
pyinfra.api.facts.get_host_fact(state: State, host: Host, cls, args: List | None = None, kwargs: Dict | None = None)
pyinfra.api.facts.get_short_facts(state: State, host: Host, short_fact, **kwargs)
pyinfra.api.facts.reload_host_fact(state: State, host: Host, cls, args: List | None = None, kwargs: Dict | None = None)