1

How can I define dependencies between tasks correctly using Fabric?

Given the following fabfile.py:

from fabric.tasks import task


@task
def clean(c):
    print(type(c))


@task(pre=[clean])
def deploy(c):
    print(type(c))

Running this fabfile.py using fab2 results in:

$ fab2 -H example.org deploy
<class 'invoke.context.Context'>
<class 'fabric2.connection.Connection'>

Why is the the first argument to the clean task different from the first argument to deploy? I would have expected that a fabric2.connection.Connection instance is passed to each of them.

How would I run commands remotely in clean?

dubbaluga
  • 2,223
  • 5
  • 29
  • 38
  • Maybe run `clean(c)` in `deploy()` without using `pre=[clean]` – furas Feb 26 '20 at 19:56
  • fabric issues [pre-task ingores hosts and executes on localhost #1968](https://github.com/fabric/fabric/issues/1968) and [fabric issues a local command instead of remote on run() #1890](https://github.com/fabric/fabric/issues/1890) – furas Feb 26 '20 at 20:09

0 Answers0