If I understand your question correctly, you want to execute commands as another user without using a prefix or using.
The sudo function accepts a user, which can be a global variable if you want.
From the docs:
fabric.operations.sudo(command, shell=True, pty=True, combine_stderr=True, user=None, quiet=False, stdout=None, stderr=None)
You can just call your tasks with
sudo(command, user=sudouser)
and install sudouser to "deploy" elsewhere.
Actually this is no different from using context:
with settings(sudo_user=sudouser): sudo(command)
In both cases, you can change this sudo_user globally.
source share