Setting the user in a script or execute resource will change the UID that the process runs as, but this is not the same as logging in as that user at the console. In particular, profile and rc scripts will not be sourced as they would during a normal login. The man page for bash explains this under the "Invocation" section:
On Wednesday, January 25, 2012 at 7:23 AM, Joseph Reynolds wrote:
> Hi Arthur,
>
> The problem is that the normal environment for hubot_user isn't being loaded during the bash resource run. Because the hubot-user is running the npm command, but has the environment of the chef-client-user, it is writing the npm logs to the chef-client-user's home folder, which it doesn't have permissions for.
>
> At least that's what it looks like to me.
>
> Joe
http://linux.die.net/man/1/bash
--
Dan DeLeo
Archive powered by MHonArc 2.6.16.