Permission to write using 'deploy' user

Ben asked:

I’m currently new to Chef and Capistrano. I’m using version 3.x of Capistrano to deploy Rails 4 application.

I have successfully bootstrapped a server using chef solo. One cookbook that I’m using is Nginx.

Back to my simple Rails 4 app, I’m trying to run this command to check the status of my deployment:

cap production deploy:check

However, it throws some error:

DEBUG [05e580a4] Command: /usr/bin/env mkdir -pv /var/www/shared /var/www/releases
DEBUG [05e580a4]    mkdir: cannot create directory `/var/www': Permission denied
DEBUG [05e580a4]    mkdir: cannot create directory `/var/www': Permission denied

I’m using deploy user for Capistrano, and on my Chef node config, I speficied the deploy user. I can also logged in on my instance using deploy user.

Is there a proper way for me to address the permissions on Chef or in Capistrano?

My answer:

The directory you intend to deploy to should already exist and have the correct ownership and permissions before you try to run Capistrano to deploy to it. So you need to handle that beforehand, probably in the same chef recipe where you created the user.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.