title: Calling multiple variables in chef code
body: <p>I have the following set in my attributes file</p>
  
  <pre><code>default[:iptables][:ports] = [22,21]
  default[:iptables][:ubnet] = ["192.168.0.0/24"]
  </code></pre>
  
  <p>I have the following in my template.erb file</p>
  
  <pre><code>-A INPUT -i lo -j ACCEPT
  
  &lt;%- node[:iptables][:ports].each do |port| -%&gt;
  
  -A INPUT -m state --state NEW -m tcp -p tcp --dport &lt;%= port %&gt; -j ACCEPT
  
  &lt;%- end -%&gt;
  
  &lt;% node[:iptables][:subnet].each do |subnet| -%&gt;
  
  -A INPUT -m state --state NEW -s &lt;%= subnet %&gt; -m tcp -p tcp --dport &lt;%= port %&gt; -j ACCEPT
  
  &lt;%- end -%&gt;
  </code></pre>
  
  <p>I want to end up with something like this when i run the code </p>
  
  <pre><code>-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
  
  -A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
  
  -A INPUT -m state --state NEW -s 192.168.0.0/16 -m tcp -p tcp --dport  25 -j ACCEPT
  </code></pre>
  
  <p>Unfortunately when i run the code as is, i get the following error</p>
  
  <pre><code>Chef::Mixin::Template::TemplateError (undefined local variable or method 'port' for #&lt;Chef::Mixin::Template::TemplateContext:0x00000006e7cd80&gt;)
  </code></pre>
  
  <p>The first half of the code works as expected but the second block is the one giving me issues. I also do not want to hard code port 25. Can someone help me rewrite this?</p>