class str, inventory: Inventory, groups, executor=<module 'pyinfra.connectors.ssh' from '/home/runner/work/pyinfra/pyinfra/pyinfra/connectors/'>)

Bases: object

Represents a target host. Thin class that links up to facts and host/group data.

connect(reason=None, show_errors: bool = True, raise_exceptions: bool = False)

Connect to the host using it’s configured connector.

property connected: bool
connection = None
connector_data: Dict[str, Any]
create_fact(name_or_cls, data=None, kwargs=None)

Create a new fact for this host in the fact cache.

current_deploy_data = None
current_deploy_kwargs = None
current_deploy_name: str | None = None
current_op_global_kwargs: Dict[str, Any]
current_op_hash: str | None = None
delete_fact(name_or_cls, kwargs=None)

Remove an existing fact for this host in the fact cache.

deploy(name: str, kwargs, data, in_deploy: bool = True)

Wraps a group of operations as a deploy, this should not be used directly, instead use pyinfra.api.deploy.deploy.


Disconnect from the host using it’s configured connector.

executing_op_hash = None
get_fact(name_or_cls, *args, **kwargs)

Get a fact for this host, reading from the cache if present.

get_file(*args, **kwargs)

Low level method to download a file from the host via it’s configured connector.

property group_data
property host_data
in_deploy: bool = False
in_op: bool = False
loop_position: List[int]
nested_executing_op_hash = None

Log a description for a noop operation.

property print_prefix
put_file(*args, **kwargs)

Low level method to upload a file to the host via it’s configured connector.

reload_fact(name_or_cls, *args, **kwargs)

Get a fact for this host without using any cached value, always re-fetch the fact data from the host and then cache it.

rsync(*args, **kwargs)
run_shell_command(*args, **kwargs)

Low level method to execute a shell command on the host via it’s configured connector.

state: State
style_print_prefix(*args, **kwargs)
class Host, *datas)

Bases: object

Combines multiple AttrData’s to search for attributes.

get(key: str, default=None)
override_datas: Dict[str, Any] List[Callable[[...], Any] | Any]) Generator[Any, Any, Any]