title: Change the default user and group from root to something attribute-driven in Chef
body: <p>I'm using chef-solo with vagrant</p>
  
  <p>Chef defaults to root for everything. I want to only use root for a couple of things but use a functional user for everything else.</p>
  
  <p>I'm basically installing a few of packages to standard locations (should be done as root).
  And, then I'm compiling a bunch of stuff to a non-standard location. I want this entire tree to be owned by non-root user/group. Can I set the default user/group to an attribute?</p>
  
  <p>More broadly, why does chef want to act as root and why is changing the default user to non-root not a more common request?</p>
  
  <p>Specifically, the <code>bash</code> resource can take a user but this is not a full login of the user. So, the home dir is still root's home dir (which the user can not write to), the group of files created is still root. So,</p>
  
  <pre><code>bash "foo" do
    user node[:globals][:username]
    code &lt;&lt;-EOH
      # do stuff
    EOH
  end
  </code></pre>
  
  <p><code>do stuff</code> is not a full login as user.</p>
  
  <p>This question is related to <a href="https://serverfault.com/questions/402881/execute-as-vagrant-user-not-root-with-chef-solo">https://serverfault.com/questions/402881/execute-as-vagrant-user-not-root-with-chef-solo</a> and the bug mentioned there that is a won't fix: <a href="http://tickets.opscode.com/browse/CHEF-1523" rel="nofollow noreferrer">http://tickets.opscode.com/browse/CHEF-1523</a> I guess I need to look closer, maybe at the environment attribute to execute: <a href="http://wiki.opscode.com/display/chef/Resources#Resources-Execute" rel="nofollow noreferrer">http://wiki.opscode.com/display/chef/Resources#Resources-Execute</a></p>