How do I get deploy:update to use sudo?

329 views
Skip to first unread message

Chad A.

unread,
May 1, 2009, 11:35:56 AM5/1/09
to Capistrano
Hi,

Like other users I've read, I'm having a permissions problem with cap
deploy:update.

svn: Can't make directory '/var/www/test/releases/20090501151100':
Permission denied

This, of course, means that svn does haven't permission to create the
directory under /var/ww/test. The owner and group of this directory
is root (as dictated by my environment).

The problem is that deploy:update does not run the "svn" and "echo"
commands as sudo:
"svn checkout -q -r306 --no-auth-cache http://svn.nightagency.com/sta/trunk/wti09
/var/www/test/releases/20090501151100 && (echo 306 > /var/www/wti-test/
releases/20090501151100/REVISION)\""

(The same situation is described by this post -
http://groups.google.com/group/capistrano/browse_thread/thread/dff88affd9c73954/cc3e335c15fd70c5?lnk=gst&q=svn+checkout+not+using+sudo#cc3e335c15fd70c5)

If I change the permission of /var/www to the user of 'set :user, 'the
user', it works okay, which means 'cap deploy:update' is not using
sudo at all.

However, this post suggests that it should be running deploy:update as
sudo: http://swik.net/Capistrano/the+%7B+buckblogs+:here+%7D+-+Home/Capistrano+2.4.0/b7dv2

(I'm using cap v2.5.5).

cap does run the deploy:setup command using sudo (as root) if I
set :admin_runner, "root'

My question then is: How do I get cap to run both the svn checkout and
the echo command using sudo?

Thanks,

Chad

Rafael G.

unread,
May 3, 2009, 3:05:07 PM5/3/09
to capis...@googlegroups.com
Hi Chad,

You can override the method deploy! (Capistrano::Deploy::Strategy)
in your deploy.rb to execute it with sudo:

module Capistrano
module Deploy
module Strategy
class Remote < Base
scm_run "#{sudo} #{command} && #{sudo} #{mark}"
end
end
end
end

I don't tested it but I hope you get the idea.

Regards
--
Rafa

Lee Hambley

unread,
May 4, 2009, 5:07:48 PM5/4/09
to capis...@googlegroups.com
Rafa,

 You should submit that as a patch, although I would tend to suggest that you should also consider fixing permissions on the sever Chad.

- Lee

2009/5/3 Rafael G. <r...@aspgems.com>
Reply all
Reply to author
Forward
0 new messages