I'm using chef to create a file resource
file "somefile" do
action :create_if_missing
end
And I want to put this in the user's home directory. I am having two issues:
- The file is interpreted relative to /, so using ~/ ends up putting the file in /~/
- I'm launching this chef recipe through vagrant and these files are being created by root. So even if I could get ~/ to work, it would end up in root's home. I don't want to hard code to use the username vagrant since it won't always be that (we may run these with chef client as well), and
node[:user]appears to be empty.
Is there a way to create a file in the non-root user (in this case vagrant) home directory?