capistrano-3-rails-template
capistrano-3-rails-template copied to clipboard
Change upload behaviour that fix permission issue
The problem happens when you, for example chown logrotate config files to root. Then permission issue will happen if deploy_user is not root.
Thanks for the PR, the tricky thing is that the smart_template
method is used for multiple files and this change would mean that every file ending up being owned by root which isn't the behaviour needed.
Potentially we need another way of indicating that certain files should be chowned to root after upload. I'll have a bit of a play over the weekend and see if I can come up with something. Any suggestions much appreciated!
No. It's not chowned after upload. I mean if your file is ALREADY chowned. So upload! method will fail because of lack of permissions.
Here is what I did previously to chown logrotate config. After this line: https://github.com/TalkingQuickly/capistrano-3-rails-template/blob/master/lib/capistrano/tasks/setup_config.cap#L29 I've added this:
sudo :chown, symlink[:chown_source], "#{shared_path}/config/#{symlink[:source]}" if symlink[:chown_source]
Now in config/deploy.rb I've added needed option
set(:symlinks, [
{
source: "nginx.conf",
link: "/etc/nginx/sites-enabled/{{full_app_name}}.conf"
},
{
source: "log_rotation",
link: "/etc/logrotate.d/{{full_app_name}}",
chown_source: "root:root"
}
])
So I can choose what user I need to be the owner. Yes, its not the universal method for every uploaded file. But I had problem with logrotate config permissions. So it works perfectly for me. I get the idea.
Facing the same issue. Trying out this solution.
Still not working.