How to run commands which require sudo using Capistrano V3?
From this page, it looks like the suggested way to use sudo with capistrano 3 is to set up passwordless sudo.
hak8or
Updated on July 24, 2022Comments
-
hak8or almost 2 years
I would like to be able to run apt-get update and then install a few new programs (tmux) along with apt-get upgrade on all my servers when running cap setup but am fumbling around with the apparent lack of documentation regarding sudo on v3.
The gotcha on the v3 release page for sudo makes me sad. http://www.capistranorb.com/2013/06/01/release-announcement.html
For example, here is how I think sudo should work based on some googling, but I keep getting asked for a password.
desc "Check that we can access everything" task :setup do on roles(:web) do uptime = capture(:uptime) info "Uptime: #{uptime}" sudo "apt-get update" end end
With the response of the following with me manually typing in the password in terminal not seeming to do anything at all (no error, no response).
DEBUG [e47a40c6] Finished in 4.646 seconds command successful. DEBUG [e47a40c6] 05:37:52 up 14:36, 3 users, load average: 0.00, 0.01, 0.05 DEBUG [e47a40c6] Finished in 4.646 seconds command successful. INFO Uptime: 05:37:52 up 14:36, 3 users, load average: 0.00, 0.01, 0.05 INFO [d194a520] Running /usr/bin/env sudo apt-get update on 192.168.1.126 DEBUG [d194a520] Command: /usr/bin/env sudo apt-get update DEBUG [d194a520] [sudo] password for deploy:
Also, is there a place I am not seeing which holds documentation that has been updated to v3?
-
hak8or over 10 yearsI looked around and found this fantastic guide for setting up pass wordless sudo for users and specific commands as per your reccomendation: davidverhasselt.com/2008/01/27/passwordless-sudo I will keep this question open for a few more days to see if anyone has a better idea or if someone points out that I am going about this wrong.