15
19

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 3でパスワードつきsudoをする方法

Last updated at Posted at 2015-03-25

Capistrano 3はパスワード入力が必要なsudoをサポートしていない訳ですが、不便なので、パスワードつきsudoするためのsshkit-sudoというgemを作ってみました。

このgemを入れ、Capfile内でrequire 'sshkit/sudo'すると、SSHKitにsudoコマンドが追加され、Capistrano 3のタスク内からsudoコマンドを呼び出すことができるようになります。

以下のように使います。

namespace :nginx do
  desc 'Reload nginx'
  task :reload do
    on roles(:web), in: :sequence do
      sudo :service, :nginx, :reload
    end
  end
end

github: sshkit-sudo
使い方: Capistrano 3でパスワード付きsudoを実行する方法

15
19
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
15
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?