Make the user an attribute and set that according to your environment.
directory "/home/#{node[:my_app][:default_user]}/my-directory" do
owner node[:my_app][:default_user]
end
Then, on your attributes/default.rb
file:
default[:my_app][:default_user] = 'ubuntu'
and on your Vagrantfile
:
Vagrant.configure("2") do |config|
config.vm.provision "chef_solo" do |chef|
# ...
chef.json = {
"my_app" => {
"default_user" => "vagrant"
}
}
end
end
This will set your default user to ubuntu
, but that will be overridden when running in the Vagrant VM.