:use_sudo, and when sudo is actually used

22 views
Skip to first unread message

Joe McDonagh

unread,
Jul 6, 2009, 12:02:20 PM7/6/09
to capis...@googlegroups.com
Hi Guys, I am trying to do a really simple website push process that
doesn't involve rails or anything really, here is my deploy.rb:

=========================================
set :application, "corpsite"
set :repository, "https://staging/site/trunk"


# If you aren't deploying to /u/apps/#{application} on the target
# servers (which is the default), you can specify the actual location
# via the :deploy_to variable:
# set :deploy_to, "/var/www/#{application}"

# If you aren't using Subversion to manage your source code, specify
# your SCM below:
# set :scm, :subversion

task :fix_perms_before do
cmd_str = "sudo bash -c 'if [ ! -e #{deploy_to}/shared/cached-copy ];
then \
mkdir -p #{deploy_to}/shared/cached-copy; \
fi'"
run cmd_str
end

namespace :deploy do
desc "Reload apache"
task :restart, :roles => :web do
run "sudo /etc/init.d/apache2 reload"
end
end

role :web, "10.1.90.80"

set :deploy_via, :remote_cache
set :copy_cache, true
set :copy_strategy, :export

set :deploy_to, "/var/www/corpsite"
set :current_deploy_dir, "#{deploy_to}/current"

set :keep_releases, 10
set :use_sudo, true

set :scm_password, "mypass"

before :deploy, :fix_perms_before
=========================================

But I get this error:

copying the cached version to /var/www/corpsite/releases/20090706142841
* executing "cp -RPp /var/www/corpsite/shared/cached-copy
/var/www/corpsite/releases/20090706142841 && (echo 3487 >
/var/www/corpsite/releases/20090706142841/REVISION)"
servers: ["10.1.90.80"]
[10.1.90.80] executing command
*** [err :: 10.1.90.80] cp: cannot create directory
`/var/www/corpsite/releases/20090706142841': Permission denied
command finished


This is the kind of thing I was hoping :use_sudo could get around...

--
Joe McDonagh
Operations Engineer
www.colonfail.com

Rafael G.

unread,
Jul 6, 2009, 3:48:48 PM7/6/09
to capis...@googlegroups.com
I hope that you need to fix the permissions in /var/www/corpsite/releases.


--
Rafa

Joe McDonagh

unread,
Jul 6, 2009, 3:56:12 PM7/6/09
to capis...@googlegroups.com
Changing permissions would be a workaround, which I'd rather not do.
root is the only user who can write to the wwwroot, www-data can read it
via a FACL. Any new files/dirs under /var/www inherit the default ACL
thus preserving www-data's ability to read the web data.

It appears that for certain pieces of the deploy tasks, use_sudo is
ignored. I've filed a bug on it, not positive what the outcome will be
but from the sound of it, Lee is going to try to get a patch in.


--

Lee Hambley

unread,
Jul 6, 2009, 4:13:17 PM7/6/09
to capis...@googlegroups.com
Hi Joe,

It's a tricky one, I can help you out with a patch you can load your self, check the ticket in a couple of minutes (or wait for an email, I'm just releasing a new capify.org (update: should be live now))

- Lee

2009/7/6 Joe McDonagh <joseph.e...@gmail.com>
Reply all
Reply to author
Forward
0 new messages