capistrano-plugins / capistrano-unicorn-nginx

Capistrano tasks for automatic and sensible unicorn + nginx configuration
MIT License
175 stars 81 forks source link

Can't execute sudo commands #5

Closed 4e4c52 closed 10 years ago

4e4c52 commented 10 years ago

Hello,

I'm trying to setup my server with your plugin but I get the following error:

DEBUG [73a16756] Command: /usr/bin/env sudo mv /tmp/covoitdeboite_production /etc/nginx/sites-available
DEBUG [73a16756]    sudo: no tty present and no askpass program specified

When I set :pty to true, I'm asked for the user password but typing it and pressing return don't do anything at all.

The user has sudo rights on the server.

What can I do?

Thanks

bruno- commented 10 years ago

Hey, I've never had that issue so I googled it. I'm guessing your deploy user does not have passwordless sudo privileges? Here are some instructions how to set that up.

Please note capistrano suggests setting up passwordless sudo with care in the authorization section here. Also, letting pty default to false also should be a ok.

In case you have more problems, please attach the contents of your /etc/sudoers file. Hope that helps!

4e4c52 commented 10 years ago

Hello,

Thanks for your answer.

Here is the relevant line in my /etc/sudoers file:

cdb     ALL=NOPASSWD:/bin/mv, /bin/ln, /bin/mkdir, /etc/init.d/nginx, [...]

Also, I removed the :pty option and the password of the user.

The commands work except for "sudo -u postgres", I don't know what I should add for it to works.

bruno- commented 10 years ago

Hey, so I didn't understand from the above message - is nginx setup now working? From what you said it seems there's now problems with the postgres command?

Here's the example of my sudoers entry. deploy user I'm using is a member of sysadmin group and the rights are more "liberal".

# Members of the group 'sysadmin' may gain root privileges
%sysadmin ALL=(ALL) NOPASSWD:ALL
4e4c52 commented 10 years ago

Hi,

Yes, the Nginx setup is now working. I know it works with you sudoers file but I'm not very confortable about giving all the rights.

Nevermind, it works that way.

Thanks! :)