title: Chef and ruby templates - how to loop though key value pairs?
body: <p>1) I have a data bag as follows:</p>
  
  <pre><code> "zookeeper":{
          "server1":"111.111.111.111",
          "server2":"222.222.222.222"
          },
  </code></pre>
  
  <p>2) In my recipe I get the hash as follows.</p>
  
  <pre><code>data_bag("mydb")
  db = data_bag_item("mydb", "rtb")
  ZOOKEEPER = db['zookeeper']
  </code></pre>
  
  <p>3) Also in my recipe I have a template as follows:</p>
  
  <pre><code>template "/etc/zookeeper/conf/zoo.cfg" do
    path "/etc/zookeeper/conf/"
    source "zoo.cfg.erb"
    owner "root"
    group "root"
    mode "0644"
   variables :zookeeper =&gt; #{ZOOKEEPER}
  end
  </code></pre>
  
  <p>4) I need to have my template look like this</p>
  
  <pre><code>server.1=111.111.111.111:2888:3888
  server.2=222.222.222.222:2888:3888
  </code></pre>
  
  <p>My question is this.  How do I pass the hash to the template so I can loop through the hash and create the temlplate?  I am not a strong ruby coder.</p>
  
  <p>for example:</p>
  
  <pre><code>count = 1
  for server, ipaddress in zookeeper:
        server.count=ipaddress:2888:3888
        count = count + 1
  </code></pre>