It seems like this should be some thing easily solved in the metadata.rb file right? This is best practice for all server management and AWS doesn’t even allow root ssh access by default so I think this needs to be better clarified in the documentation, unless I’ve just missed something obvious.
So you can run bash/execute/etc resources as another user, typically needing to set the user and environment variables. That said, Chef is designed to configure servers and most of those operations will require root-level access to perform, so that’s not exactly a traditional use case to run an entire recipe as another user.
Can I ask what you’re actually trying to achieve in more detail? Like why do you need it to run as the ubuntu user? Chef expects to run as root and while it is possible to run certain pieces of a recipe as another user if you want or need to, you probably won’t be able to run an entire Chef run as a non-root user, even a privileged non-root user.
Right now Im just using AWS OpsWorks to configure the servers so its running chef-client for me. (Sorry I’m a nood at chef and am not fully clear on the different moving parts)
Is there a way to do the same thing with my current set-up? I’ve gotten around my problem using this the code in my last comment, but would love a cleaner way run the entire recipe as different user.
application_javascript covers running a Node app as a non-root user. You can set the user at the app owner or service user level (you probably want the latter since apps shouldn’t generally have write access to their own code).