2

My capifony deployment works great, however the capifony cleanup command fails.

I'm using private keys over ssh, with sudo to gain write permissions on the deployment directories.

With extended logging the result of cap deploy:cleanup is this:

$ cap deploy:cleanup
* 2013-07-19 15:44:42 executing `deploy:cleanup'
* executing "sudo -p 'sudo password: ' ls -1dt /var/www/html/releases/* | tail -n +4 | sudo -p 'sudo password: ' xargs rm -rf"

Modifying permissions so that the deployment user has full write access to this directory is not an option in this instance.

Has anyone seen/worked around this issue? (This is on a RHEL6 server)

james_t
  • 2,723
  • 1
  • 15
  • 20

1 Answers1

4

Yep, there is a problem with the cleanup command while using sudo at the moment. Here was my solution to fixing this. Add this to your deploy.rb

  namespace :customtasks do
    task :customcleanup, :except => {:no_release => true} do
      count = fetch(:keep_releases, 5).to_i
      run "ls -1dt #{releases_path}/* | tail -n +#{count + 1} | #{try_sudo} xargs rm -rf"
    end
  end

Then call that instead as cleanup

after "deploy:update", "customtasks:customcleanup"

More info at https://github.com/capistrano/capistrano/issues/474

Kevin Carmody
  • 2,311
  • 2
  • 23
  • 23