Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>So it seems there's some disconnect on the understanding of how this is meant to work.</p> <p>When writing a recipe, it's common to use node attributes to define where thing will end up - such as your web_root directory.</p> <p>I can conceive of the recipe's attributes file containing:</p> <pre><code>default['base_directory'] = '/var/www/html' </code></pre> <p>Which would apply to many production servers out there.</p> <p>Then, when writing your recipes, use this attribute to send the files where you want them to, e.g.:</p> <pre><code>cookbook_file "#{node['base_directory']/css/myfile.css" do owner "root" ... end </code></pre> <p>When sharing your cookbook, anyone executing this on a server that has the <code>/var/www/html</code> directory will receive your file in the correct place.</p> <p>In your Vagrantfile, in order to override the node's <code>base_directory</code> attribute to the synced directory, you can do something like this:</p> <pre><code>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" =&gt; SYNCED_FOLDER } end end </code></pre> <p>However, you mentioned that you didn't want to have to specify <code>base_directory</code> in your recipes, so I'd ask what node attribute you are using to drive the target location of your web root?</p> <p>If you're using something like the apache2 cookbook from the Community site, then there's <a href="https://github.com/opscode-cookbooks/apache2/blob/master/attributes/default.rb#L33" rel="nofollow">already an attribute</a> for this: <code>node['apache']['docroot_dir']</code>, so using that you can control where thing are referenced.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload