python - Fabric: do everything as a particular user -


my build , production deployment connected using keys 1 user particular user shared across deployment , keys copied on during machine spin up.

this user deploy, has ssh keys shared allowing ssh prod machine , between them.

now fabric build runs user jenkins.

how instruct fabric execute particular user(deploy in case)?the equivalent of sudo su deploy

i don’t want prefix or with in every task. rather set global variable.

jenkins in wheel group , has sudo perms

if understand question correctly, want execute commands user without using prefix or with.

the sudo function accepts user can global variable, if like.

from docs:

fabric.operations.sudo(command, shell=true, pty=true,                         combine_stderr=true, user=none,                         quiet=false, stdout=none, stderr=none) 

you can call tasks with

sudo(command, user=sudouser) 

and set sudouser 'deploy' elsewhere.

in fact, no different using context:

with settings(sudo_user=sudouser):       sudo(command) 

in both cases, should able change sudo_user globally.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -