pyinfra.api.operation module

Operations are the core of pyinfra. The @operation wrapper intercepts calls to the function and instead diff against the remote server, outputting commands to the deploy state. This is then run later by pyinfra’s __main__ or the pyinfra.api.operations module module.

class pyinfra.api.operation.OperationMeta(hash=None, commands=None)

Bases: object

combined_output_lines = None
set_combined_output_lines(combined_output_lines)
property stderr
property stderr_lines
property stdout
property stdout_lines
pyinfra.api.operation.add_op(state, op_func, *args, **kwargs)

Prepare & add an operation to pyinfra.state by executing it on all hosts.

Parameters
  • state (pyinfra.api.State obj) – the deploy state to add the operation
  • op_func (to) – the operation function from one of the modules,
  • server.user (ie) –
  • args/kwargs – passed to the operation function
pyinfra.api.operation.operation(func=None, pipeline_facts=None, is_idempotent=True, idempotent_notice=None, frame_offset=1)

Decorator that takes a simple module function and turn it into the internal operation representation that consists of a list of commands + options (sudo, (sudo|su)_user, env).

pyinfra.api.operation.show_state_host_arguments_warning(call_location)