Search code examples
pythondeploymentsudofabric

Fabric Sudo No Password Solution


This question is about best practices. I'm running a deployment script with Fabric. My deployment user 'deploy' needs sudo to restart services. So I am using the sudo function from fabric to run these commands in my script. This works fine but prompts for password during script execution. I DON'T want to type a password during deployments. What's the best practice here. The only solution I can think of is changing the sudo permissions to not require password for the commands my deployment user runs. This doesn't seem right to me.


Solution

  • As Bartek also suggests, enable password-less sudo for the deployment 'user' in the sudoers file.

    Something like:

    run('echo "{0} ALL=(ALL) ALL" >> /etc/sudoers'.format(env.user))