So it seems there's some disconnect on the understanding of how this is meant to work.
When writing a recipe, it's common to use node attributes to define where thing will end up - such as your web_root directory.
I can conceive of the recipe's attributes file containing:
default['base_directory'] = '/var/www/html'
Which would apply to many production servers out there.
Then, when writing your recipes, use this attribute to send the files where you want them to, e.g.:
cookbook_file "#{node['base_directory']/css/myfile.css" do
owner "root"
...
end
When sharing your cookbook, anyone executing this on a server that has the /var/www/html
directory will receive your file in the correct place.
In your Vagrantfile, in order to override the node's base_directory
attribute to the synced directory, you can do something like this:
SYNCED_FOLDER = "/synced/dir/on/vm"
Vagrant.configure("2") do |config|
config.vm.synced_folder ".", SYNCED_FOLDER
config.vm.provision :chef_solo do |chef|
chef.json = {
"base_directory" => SYNCED_FOLDER
}
end
end
However, you mentioned that you didn't want to have to specify base_directory
in your recipes, so I'd ask what node attribute you are using to drive the target location of your web root?
If you're using something like the apache2 cookbook from the Community site, then there's already an attribute for this: node['apache']['docroot_dir']
, so using that you can control where thing are referenced.