TechCompose
TechCompose

Reputation: 53

How to run sudo command with password in capistrano

I want to run my Httpd service to restart by Capistano, so I write this code for that

namespace :deploy do
  task :restart do
    on roles(:app), in: :sequence, wait: 1 do
        within current_path do
          execute "service httpd restart"         
        end
    end
  end
end
after :deploy, 'deploy:restart'

but when it cap file execute this line it is asking for the user's password, but I need to run this command with root user.

Please let me know how to execute this command with root user.

Upvotes: 1

Views: 1290

Answers (2)

will_in_wi
will_in_wi

Reputation: 2653

The Capistrano documentation recommends adding this particular command to passwordless-sudo:

http://capistranorb.com/documentation/getting-started/authentication-and-authorisation/#authorisation

Then you can call sudo without being prompted for a password.

Upvotes: 0

Pandya M. Nandan
Pandya M. Nandan

Reputation: 682

better try with sudoer user, than adding it to code for prompt.

Upvotes: 1

Related Questions