pyinfra.api.operation¶
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.
-
class
pyinfra.api.operation.OperationMeta(hash=None, commands=None)¶ Bases:
object
-
pyinfra.api.operation.add_limited_op(state, op_func, hosts, *args, **kwargs)¶ Prepare & add an operation to pyinfra.state by executing it on all hosts.
Parameters: - state (
pyinfra.api.Stateobj) – the deploy state to add the operation to - op_func (function) – the operation function from one of the modules, ie
server.user - hosts (
pyinfra.api.Hostobj or list) – hosts this operation will be limited to - args/kwargs – passed to the operation function
- state (
-
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.Stateobj) – the deploy state to add the operation to - op_func (function) – the operation function from one of the modules, ie
server.user - args/kwargs – passed to the operation function
- state (
-
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).