title: how to create a data bag as part of chef script
body: <p>I need to create a data bag and then an data bag item <strong>USING CHEF RECIPE</strong>. I an unable to do so.
  I have the content also ready which is as follows </p>
  
  <pre><code>require 'rubygems'
  require 'chef/encrypted_data_bag_item'
  
  secret = Chef::EncryptedDataBagItem.load_secret('/root/data_bag')
  data = {"id" =&gt; "TEST", "root" =&gt; "root", "passwd" =&gt; "passwd"}
  encrypted_data = Chef::EncryptedDataBagItem.encrypt_data_bag_item(data, secret)
  </code></pre>
  
  <p>Now that i have the content , i need to create a data bag and an item , and then append the content in to that item . this is the approach which i tried for creating a data bag. But it failed.</p>
  
  <pre><code>new_databag = Chef::DataBag.new
  new_databag.name('list')
  new_databag.save
  </code></pre>
  
  <p>when i am using <code>new_databag.save</code> its saying forbidden.  </p>
  
  <p>Below is the snippet for creating the data bag item,which i got it over the internet. but how do we specify the item name which we want to give.  </p>
  
  <pre><code>item = Chef::DataBagItem.new
  item.data_bag('list')
  item.raw_data = data
  item.save
  </code></pre>
  
  <p>Any help would be appreciated ..!!</p>