2

I use fabric2 in terminal and I don't want input -H 'hosts' every time.

How can I do it?

e.g.

// actual
fab2 -H web1 upload_and_unpack
// expected
fab2 upload_and_unpack

I've read the main doc, configuration doc but found nothing.

2
  • I read the source code, it same not options for that.
    – zwidny
    Commented May 24, 2018 at 16:34
  • 1
    Can you specify the actual command that you are running and give an example of what you would like to achieve if it were possible so we can better understand the question? You can edit the question to add more detail. Also, command line/bash question are better asked on linux stack exchange probably. Commented May 24, 2018 at 18:49

1 Answer 1

2
from fabric import task

@task(hosts=['web1'])
def upload_and_unpack(c):
    c.run('uname -a')

If you define your fabfile as above, then you can simple run your fab command without providing any host parameter (assuming that web1 is already defined in your ssh config file).

$ fab upload_and_unpack

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.