2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Capistranoのdeploy:cleanupで「incorrect password attempt」が出て実行できない時の対応

Posted at

Capistranoのdeploy:cleanupで過去のデプロイ履歴を削除できるのですが、環境(Linux)によってはうまくいかない場合があります。

SUDOを使用して、例えばroot権限などでファイルを削除しようとするのですが、
「1 incorrect password attempt」というメッセージが出たり、何度もパスワードを聞かれたりしてうまくいきません。

どうも、パスワードの最後に改行コードが無くて、どこまでがパスワードなのかOS側が認識できていないようです。

仕方ないので、deploy.rb内でcleanupタスクをオーバーライドして対応しました。


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

やっていることは、通常のcleanupとなんら変わらないのですが、runで実行すると、うまく動きます。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?