title: Chef: Can you add elements to an attribute list from a dependent cookbook
body: <p>So I am pretty green on chef and ruby. I am working have been making a cookbook to install influxdb's telegraf. I have devised a system for this recipe to generate custom configurations based on a list of attributes stored in a default attribute hash. </p>
  
  <p>Now I would like to extend this so that dependent cookbooks can add to the attribute that generates the config so that I can add new configurations to the telegraf config without the telegraf config having to be responsible for the partial template config introduced by the cookbook using it. here is the approach. </p>
  
  <p>in my telegraf cookbook I have default attribute like so</p>
  
  <pre><code>default['telegraf']['config']['partials'] = [
      {
              variables: { hostname: "hostname" },
              templateName: 'output-win-perf-influxdb.erb',
      },
      {
              variables: {},
              templateName: 'input-win-perf-statsd.erb',
      },
      {
              variables: {},
              templateName: 'input-win-perf-system.erb',
      }
  ]
  </code></pre>
  
  <p>and which is used in this template resource </p>
  
  <pre><code>template 'C:\\Program Files\\telegraf\\telegraf.conf' do
    source 'telegraf/telegraf.conf.erb'
    action :create
    variables (node.default['telegraf']['config'])
  end
  </code></pre>
  
  <p>The partials get rendered into telegraf.conf with </p>
  
  <pre><code>&lt;% @partials.each do |partial| %&gt;
  &lt;%= render "telegraf/partials/#{partial['templateName']}", :variables =&gt; partial['variables']%&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Now to test how this extends to dependent cookbooks I created a new cookbook that depends on <code>win-telegraf</code>. In the new cookbook I attempted to add to the list of <code>partials</code> like so </p>
  
  <pre><code>default['telegraf']['config']['partials'].push(
          {
                  variables: { environments: ["chi", "main"] },
                  templateName: 'test.erb',
          }
  )
  </code></pre>
  
  <p>I kinda expected this to fail because it wouldnt be able to find the .erb for the new partial template. But looking at the run log it doesnt even appear that the new item was added to the array. I went with an array to maintain order, but might have to take a different approach if this is not possible. </p>