CentOS 5 Configuration Tweak for sudo
Posted by Scott on Feb 17th, 2008
I recently updated my Rails deployment server from CentOS 4 to CentOS 5, and immediately ran into the following error when deploying my apps using vlad:
sudo: sorry, you must have a tty to run sudo
Thus apache wasn’t being restarted after my mongrel instances. It turns out that RHEL/CentOS 5 includes added restrictions in its default sudo configuration. Simply comment out the following line in /etc/sudoers:
#Defaults requiretty
to resolve the problem.
May 6th, 2008 at 2:49 am
Excellent!
Works as a charm for me. Thanks!
May 9th, 2008 at 10:26 am
Another way around this is to modify your Capistrano setup rather than /etc/sudoers on the deployment target. If you look in the Capistrano recipes (on my Mac it’s in /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/capistrano-2.0.0/lib/capistrano/recipes.rb), there’s a note in there about a setting to turn off “sudo” in favor of “run”. So in your application’s deploy.rb (for a rails app it’s app_dir/config/deploy.rb), you can just put in the line:
set :use_sudo, false
This worked for me on a fairly vanilla RHEL 5 deployment target from a Mac OS Leopard dev machine. Probably would work on CentOS as well.
June 20th, 2008 at 5:44 am
Thanks Man, I was struck by this for 5 hours.
June 3rd, 2010 at 7:53 am
Or even easier.
add the following to your deploy.rb file
default_run_options[:pty] = true
April 4th, 2011 at 8:55 am
Thanks!!! It helped me.