3 ms·
Ask YC: Capistrano help w/ sudo
Hello All,
I'm at my wits end here...
I'm using capistrano 2.1.
I'm overwriting the finalize_update task in my deploy script to run sudo so that I can perform some misc linux calls. Here's a sample call:
task :finalize_update, :except => { :no_release => true } do
# chown the new directory to apache:apache
run "sudo -p 'sudo password:' chown -R apache:apache #{latest_release}"
end
I do see the 'sudo password:' prompt, however anything I type appears on the terminal and hitting enter doesn't send my password over. Prior to the sudo call, when I'm prompted for a password, I don't see my character inputs on the screen, typical of entering passwords in linux terminal,...so it appears that the sudo password prompt is broken. Is there a setting that I have not configured properly?
I've been searching google, and part of the new features for capistraion 2.1 is that it recognizes the '-p' option on sudo. As quoted:
Use sudo -p switch to set sudo password prompt to something predictable.
I don't understand this statement. What password prompt is "something predictable"?
Thanks for any help!
- lsc 19y agothe best way to do it would be to change you sudoers config so your task can do that without a password run visudo and add the following line: [user] ALL=(root) NOPASSWD:/bin/chown /path/to/apache /path/to/apache should be the directory above your latest_release dir so you can avoid a wildcard
- halbertn 19y agoThanks guys! I figured it out. Instead of using 'run sudo...', I can use the helper function 'sudo' directly. Now the password prompts work correctly.