Reputation: 6516
I'm trying to do an uncomplicated Rails/Capistrano deployment to a remote server. Unfortunately I can't get sudo
to run correctly out of the box. I need to deploy here:
drwxr-xr-x 2 user www 4096 Sep 28 15:05 my_app_dir
and sudoers has been set up to allow me to run sudo su - user
and that's it.
Some attempts to coax this into working from deploy.rb:
set :use_sudo, true
set :sudo, 'sudo su - user' # fails due to bad su syntax, -c is inserted after user
set :sudo, 'sudo -u user' # fails because it's not set up
set :sudo, 'sudo su - user -c' # also bad syntax
set :sudo_prompt, ''
I gather than the best options are to either:
sudo
(recommended here)sudo -u user
, which should work with set :sudo, 'sudo -u user'
Any ways to make this work as is?
Upvotes: 5
Views: 2019
Reputation: 2345
Is your user that you're trying to use added to the sudoers cfg on the server? Try this
run "#{sudo :as => 'bob'} mkdir /path/to/dir"
Upvotes: 1