AAS
AAS

Reputation: 131

Fabric 2 global settings for mutiple @tasks in fabfile.py

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?

Upvotes: 2

Views: 240

Answers (0)

Related Questions