pyinfra.api.state module

class pyinfra.api.state.BaseStateCallback

Bases: object

static host_before_connect(state: State, host: Host)
static host_connect(state: State, host: Host)
static host_connect_error(state: State, host: Host, error)
static host_disconnect(state: State, host: Host)
static operation_end(state: State, op_hash)
static operation_host_error(state: State, host: Host, op_hash)
static operation_host_start(state: State, host: Host, op_hash)
static operation_host_success(state: State, host: Host, op_hash)
static operation_start(state: State, op_hash)
class pyinfra.api.state.State(inventory: Inventory | None = None, config: Config | None = None, **kwargs)

Bases: object

Manages state for a pyinfra deploy.

activate_host(host: Host)

Flag a host as active.

add_callback_handler(handler)
config: Config
current_deploy_filename: str | None = None
current_exec_filename: str | None = None
current_op_file_number: int = 0
cwd: str | None = None
fail_hosts(hosts_to_fail, activated_count=None)

Flag a set of hosts as failed, error for config.FAIL_PERCENT.

get_op_data(host: Host, op_hash: str)
get_op_meta(op_hash: str)
get_op_order()
get_temp_filename(hash_key: str | None = None, hash_filename: bool = True)

Generate a temporary filename for this deploy.

init(inventory: Inventory, config: Config | None, initial_limit=None)
initialised: bool = False
inventory: Inventory
is_executing: bool = False
is_host_in_limit(host: Host)

Returns a boolean indicating if the host is within the current state limit.

pool: Pool
preserve_loop_order(items)
print_fact_info: bool = False
print_fact_input: bool = False
print_fact_output: bool = False
print_input: bool = False
print_noop_info: bool = False
print_output: bool = False
set_op_data(host: Host, op_hash: str, op_data)
to_dict()
trigger_callbacks(method_name: str, *args, **kwargs)