Capistrano using sudo, even with "set: use_sudo, false"

I do not want to use sudo for any of my remote commands using Capistrano. In particular, when I run cap deploy:setup , they ask me for my sudo password during the first mkdir command. I added set :use_sudo, false to the deploy.rb file, but that didn't help.

I started with a fairly complete deploy.rb file, but reduced it as soon as I had problems. Here is my minimal version that still does not comply with use_sudo :

 # App Definitions set :domain, '[server-ip]' role :app, domain role :web, domain role :db, domain, :primary => true set :user, "my_app" set :use_sudo, false task :sudo_test do run "#{try_sudo} whoami" end 

running cap sudo_test causes me to be prompted for a sudo password. What am I missing here (except for the hair that I have already pulled out)?

Google Results

https://groups.google.com/forum/?fromgroups#!topic/capistrano/QNYnvW8obrg

Feed with someone having a similar problem. No conclusion / resolution noted in the stream.

+7
source share
2 answers

Apparently, it is not possible to disable sudo functions with certain capistrano tasks. It is assumed that an unprivileged user on the server will not be able to perform certain tasks.

The corresponding mkdir command. I argue that an unprivileged user should be able to run this command if the parent folder is the one for which they have permission to do this. I also claim that the user can be a privileged user, such as root. Best practice Not necessary. As part of a reasonable deployment, yes.

Here is a link to the answer to my original question:

https://github.com/capistrano/capistrano/issues/211#issuecomment-7667467

+4
source

For someone else who is facing this problem and is as stupid as I am. Make sure you do not specify a lie. I have had:

 set :use_sudo, "false" 

and when I switched it to

 set :use_sudo, false 

most things started working as i expected. As YWCA Hello points out, there are more commands that ignore the use_sudo parameter. However, be sure to install it correctly.

+12
source

All Articles