I've been battling with umask/permission problems for a while now in various cases. I have set www-data (run by nginx/php-fpm) to have a umask of 002 in the /etc/init/php-fpm.conf file, and my deployer user also has umask of 002 in /home/deployer/.bashrc. The application files all have the 0660 permissions (0770 for directories) so that they both can read/write them (the deployer's main group is www-data). However I keep running into cases where this umask is not getting honored, and files are set to 644 or 640.
My current case is when SSHing in as root using an ansible script, with the options of:
sudo: yes
sudo_user: deployer
Files created with ansible are getting file permissions of 644. How do I see where umask is getting set, and where to add the umask?
Secondly is there not a better way to do deployment? I would like to just avoid this issue completely and do all deployment work as the www-data user, but apparently that's a security issue. This umask stuff is really complicated deployment.
Thank you.