

Ask YC: Capistrano help w/ sudo - halbertn

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:<p><pre><code>  task :finalize_update, :except =&#62; { :no_release =&#62; true } do
    # chown the new directory to apache:apache
    run "sudo -p 'sudo password:' chown -R apache:apache #{latest_release}"
  end
</code></pre>
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?<p>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:<p>Use sudo -p switch to set sudo password prompt to something predictable.<p>I don't understand this statement. What password prompt is "something predictable"?<p>Thanks for any help!
======
halbertn
Thanks guys! I figured it out. Instead of using 'run sudo...', I can use the
helper function 'sudo' directly. Now the password prompts work correctly.

------
lsc
the 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

