# 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`

`pyinfra.api.operation.``add_limited_op`(state, op_func, hosts, *args, **kwargs)

  DEPRECATED: please use `add_op` with the `hosts` kwarg.

`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.``get_operation_names`()

  Returns a list of available operations.

`pyinfra.api.operation.``operation`(func=None, pipeline_facts=None)

  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).