pyinfra.api.host module¶
- class pyinfra.api.host.Host(name: str, inventory: Inventory, groups, connector_cls=<class 'pyinfra.connectors.ssh.SSHConnector'>)¶
Bases:
object
Represents a target host. Thin class that links up to facts and host/group data.
- T = ~T¶
- arguments(**arguments: Unpack['AllArguments'])¶
- check_can_rsync() None ¶
- connect(reason=None, show_errors: bool = True, raise_exceptions: bool = False)¶
Connect to the host using it’s configured connector.
- connected: bool = False¶
- connector: BaseConnector¶
- connector_cls: type[BaseConnector]¶
- connector_data: dict[str, Any]¶
- current_deploy_data: dict[str, Any] | None = None¶
- current_deploy_kwargs = None¶
- current_deploy_name: str | None = None¶
- current_op_deploy_data: dict[str, Any] | None = None¶
- current_op_global_arguments: 'AllArguments' | None = None¶
- current_op_hash: str | None = None¶
- deploy(name: str, kwargs: 'AllArguments' | None, data: dict | None, 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() None ¶
Disconnect from the host using it’s configured connector.
- executing_op_hash: str | None = None¶
- get_deploy_data()¶
- get_fact(name_or_cls: Type[FactBase[T]], *args, **kwargs) T ¶
- get_fact(name_or_cls: Type[ShortFactBase[T]], *args, **kwargs) T
Get a fact for this host, reading from the cache if present.
- get_file(*args, **kwargs) bool ¶
Low level method to download a file from the host via it’s configured connector.
- get_temp_filename(hash_key: str | None = None, hash_filename: bool = True)¶
Generate a temporary filename for this deploy.
- property group_data¶
- property host_data¶
- in_callback_op: bool = False¶
- in_deploy: bool = False¶
- in_op: bool = False¶
- log(message: str, log_func: ~typing.Callable[[str], ~typing.Any] = <bound method Logger.info of <Logger pyinfra (WARNING)>>) None ¶
- log_styled(message: str, log_func: ~typing.Callable[[str], ~typing.Any] = <bound method Logger.info of <Logger pyinfra (WARNING)>>, **kwargs) None ¶
- loop(iterable)¶
- loop_position: list[int]¶
- nested_executing_op_hash: str | None = None¶
- noop(description: str) None ¶
Log a description for a noop operation.
- property print_prefix: str¶
- put_file(*args, **kwargs) bool ¶
Low level method to upload a file to the host via it’s configured connector.
- rsync(*args, **kwargs) bool ¶
- run_shell_command(*args, **kwargs) tuple[bool, CommandOutput] ¶
Low level method to execute a shell command on the host via it’s configured connector.
- style_print_prefix(*args, **kwargs) str ¶
- when(condition: Callable[[], bool])¶
- class pyinfra.api.host.HostData(host: Host, *datas)¶
Bases:
object
Combines multiple AttrData’s to search for attributes.
- dict()¶
- get(key: str, default=None)¶
- override_datas: dict[str, Any]¶
- pyinfra.api.host.extract_callable_datas(datas: list[Callable[[...], Any] | Any]) Generator[Any, Any, Any] ¶