Can I use variables with iptables cookbook?


#1

I use iptables cookbook version 4.2.0
https://supermarket.chef.io/cookbooks/iptables
When I try this

iptables_rule 'firewall-rules' do
  action :enable
  variables(
    :net_interface => node['network']['default_interface'],
    :ipaddress => node['ipaddress']
  )
end

I get

 ================================================================================
      Error executing action `create` on resource 'template[/etc/iptables.d/firewall-rules]'
 ================================================================================
      
      Chef::Mixin::Template::TemplateError
      ------------------------------------
      undefined method `"\xC2\xA0"' for #<Chef::Mixin::Template::TemplateContext:0x00000005237648>
      
      Resource Declaration:
      ---------------------
      # In /var/chef/cache/cookbooks/iptables/resources/rule.rb
      
       37:     template "/etc/iptables.d/#{new_resource.name}" do
       38:       source new_resource.source ? new_resource.source : "#{new_resource.name}.erb"
       39:       mode '0644'
       40:       cookbook new_resource.cookbook if new_resource.cookbook
       41:       variables new_resource.variables
       42:       backup false
       43:       notifies :run, 'execute[rebuild-iptables]', :delayed
       44:     end
       45:   else
      
      Compiled Resource:
      ------------------
      # Declared in /var/chef/cache/cookbooks/iptables/resources/rule.rb:37:in `block in class_from_file'
      
      template("/etc/iptables.d/firewall-rules") do
        action [:create]
        retries 0
        retry_delay 2
        default_guard_interpreter :default
        source "firewall-rules.erb"
        variables {:net_interface=>"ens32", :ipaddress=>"1.1.1.1"}
        declared_type :template
        cookbook_name "nas-full16"
        owner nil
        group nil
        mode "0644"
        path "/etc/iptables.d/firewall-rules"
        verifications []
      end
      
      Template Context:
      -----------------
      on line #34
       32: *nat
       33: ## Enable nat for local addresses
       34: -A POSTROUTING -o <%= @net_interface %> -j SNAT --to-source <%= @ipaddress %> --jump MASQUERADE