5

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:

  1. Enable password-less sudo (recommended here)
  2. Enable sudo -u user, which should work with set :sudo, 'sudo -u user'

Any ways to make this work as is?

jordanpg
  • 6,386
  • 4
  • 46
  • 70
  • 1
    @whoever is voting to close as "off topic": from the FAQ, relevant types of questions include "software tools commonly used by programmers". That would include Capistrano. The code with the `set :sudo`s is ruby code. – jordanpg Nov 01 '12 at 04:45

1 Answers1

1

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"

source

Máté
  • 2,294
  • 3
  • 18
  • 25