title: How do I use Chef data bags from my Vagrantfile?
body: <p>I am attempting to use <a href="http://fnichol.github.io/chef-user/" rel="nofollow">Fnichol's Chef User</a> recipe with Vagrant to automatically create a specific user account when I run <code>vagrant up</code>. Because I setup this user for nearly every project that I work on, I'd like to store the user data in a <code>data bag</code> that I am loading from a JSON file that I can re-use on multiple projects.</p>
  
  <p>This is what my <code>Vagrantfile</code> currently looks like: <a href="http://pastebin.com/b0riZZCz" rel="nofollow">http://pastebin.com/b0riZZCz</a></p>
  
  <p>It fails with the error:</p>
  
  <pre><code>[2014-01-20T16:09:39+00:00] ERROR: could not find recipe ben for cookbook user
  </code></pre>
  
  <p>I have created a <code>data bag</code> called "users" and inside that data bag I've created a <code>data bag item</code> named "ben" from the following JSON:</p>
  
  <pre><code>{
    "id": "ben",
    "comment": "Ben Harold",
    "groups": ["admin", "www-data"],
    "ssh_keys": ["...longtextstring..."],
    "ssh_keygen": false
  }
  </code></pre>
  
  <p>I'm attempting to follow the usage instructions at <a href="http://fnichol.github.io/chef-user/" rel="nofollow">http://fnichol.github.io/chef-user/</a> to:</p>
  
  <ol>
  <li>Import the Chef Users recipe</li>
  <li>Tell the Chef Users recipe to create the user <code>ben</code> from the data bag <code>users</code></li>
  </ol>
  
  <p>It appears to me that the Chef provisioning syntax from within a <code>Vagrantfile</code> is considerably different than the syntax that is presented in most of the available documentation. For example:</p>
  
  <blockquote>
    <p>"Simply include <code>recipe[user]</code> in your <code>run_list</code> and the <code>user_account</code>
    resource will be available."</p>
  </blockquote>
  
  <p>I'm confused as to the definition of <code>run_list</code>, as well as the <code>recipe[user]</code> syntax. From the <a href="http://docs.vagrantup.com/v2/provisioning/chef_solo.html" rel="nofollow">Vagrant documentation</a>, it seems that my <code>run_list</code> is everything in this block:</p>
  
  <pre><code>config.vm.provision :chef_solo do |chef|
    chef.add_recipe "apt"
    ...etc...
  end
  </code></pre>
  
  <p>However, I've <a href="http://www.iflowfor8hours.info/2013/11/vagrant-and-databags-learning-experience/" rel="nofollow">also found references</a> to <code>chef.run_list</code> being defined within that block, although I have not been able to find any documentation specifically referring to <code>chef.run_list</code>.</p>
  
  <h2>Question 1</h2>
  
  <p>Is the <code>run_list</code> simply the code within the <code>config.vm.provision :chef_solo do |chef|</code> block, or is it something else?</p>
  
  <h2>Question 2</h2>
  
  <p>Where is the documentation for <code>chef.run_list</code>? I'm not looking for the documentation on the Chef site. The syntax seems completely different to me.</p>
  
  <p>I've been messing with this for several hours. I've tried a bunch of stuff that does not work. I am able to import the <code>Chef User</code> recipe, but I haven't been able to figure out how to tell Chef to run the <code>user</code> recipe against the <code>data bag item</code> "ben".</p>
  
  <h2>Question 3</h2>
  
  <p>How do I get Chef to run the <code>user</code> recipe with the <code>data bag item</code> "ben"? Or am I doing it completely wrong?</p>