Capistrano deploys how to use use_sudo and admin_runner

I am trying to configure Capistrano to work for our server setup. We are deploying symfony projects, so I also use capifony. I am still experiencing some permission issues.

On our server, each project works as a user of the project, so each project has its own user. Therefore, I configured use_sudo and set it to true, and I configured admin_runner as a project user. But it still didn't work, so I changed capifony to start using try_sudo instead of the usual run. This made him work a little better. But I'm a little confused about what to use in this case. You have try_sudo, sudo and run. But why do you need a precedent?

  • When you use run , I think it will always be your local user
  • try_sudo I think it will check if the use_sudo flag is true if it will use the sudo command if it will not use the local user. If you have admin_runner configured, it will obey the user configured as admin_runner
  • sudo will always try sudo

Now my problem is the deploy: symlink method, it is also just a regular run command, so it runs as a local user, which gives permission problems when trying to browse the website.

So can someone tell me if my 3 teams are correctly indicated? and also does anyone know how admin_runner and use_sudo are supposed to be used, so that symlink also executes correctly (as well as all other commands executed by capistrano)?

Respectfully,

Daan

+6
source share
1 answer

Apologies for Daan’s belated reply. Your understanding of Capistrano is correct. Also note that the :use_sudo flag is true by default.

In Capistrano 2.11.2 you will find lib / capistrano / configuration / variables.rb:

 _cset(:run_method) { fetch(:use_sudo, true) ? :sudo : :run } 

and lib / capistrano / recipes / deploy.rb:

 def try_sudo(*args) options = args.last.is_a?(Hash) ? args.pop : {} command = args.shift raise ArgumentError, "too many arguments" if args.any? as = options.fetch(:as, fetch(:admin_runner, nil)) via = fetch(:run_method, :sudo) if command invoke_command(command, :via => via, :as => as) elsif via == :sudo sudo(:as => as) else "" end end 

Perhaps your permission problem is related to your server acting as a normal user, unable to read the contents of the release directory referenced by the current symlink?

+4
source

Source: https://habr.com/ru/post/903122/


All Articles