2

I'm using fabric 2.5, my fabfile looks like this:

# -*- coding: utf-8 -*-
from fabric import Connection
from fabric import task


@task
def sudowhoami(context):
    context.config.sudo['password'] = context.connect_kwargs.password
    context.sudo('whoami')

@task
def sudotask(context):
    context.config.sudo['password'] = context.connect_kwargs.password
    context.sudo('cat /root/secret')

and I run it with fab -H server.address --prompt-for-login-password sudotask so fabric asks me for password and same password I use for sudo() calls.

Is there any method to not duplicate sudo password code and define global config inside fabfile.py?

AAS
  • 111
  • 2
  • 6

0 Answers0