+default[:networking][:firewall][:inet] = []
+default[:networking][:firewall][:inet6] = []
default[:networking][:interfaces] = {}
default[:networking][:nameservers] = []
default[:networking][:search] = []
#
define :firewall_rule, :action => :accept do
- inet = nil
- inet6 = nil
-
- begin
- inet = resources(:template => "/etc/shorewall/rules")
- inet6 = resources(:template => "/etc/shorewall6/rules")
- rescue
- end
-
rule = Hash[
:action => params[:action].to_s.upcase,
:source => params[:source],
]
if params[:family].nil?
- inet.variables[:rules] << rule unless inet.nil?
- inet6.variables[:rules] << rule unless inet6.nil?
+ node.default[:networking][:firewall][:inet] << rule
+ node.default[:networking][:firewall][:inet6] << rule
elsif params[:family].to_s == "inet"
- inet.variables[:rules] << rule unless inet.nil?
+ node.default[:networking][:firewall][:inet] << rule
elsif params[:family].to_s == "inet6"
- inet6.variables[:rules] << rule unless inet6.nil?
+ node.default[:networking][:firewall][:inet6] << rule
else
log "Unsupported network family" do
level :error
owner "root"
group "root"
mode 0o644
- variables :rules => []
+ variables :family => "inet"
notifies :restart, "service[shorewall]"
end
owner "root"
group "root"
mode 0o644
- variables :rules => []
+ variables :family => "inet6"
notifies :restart, "service[shorewall6]"
end
# ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE
# PORTS PORTS DEST LIMIT
-<% @rules.each do |r| -%>
+<% node[:networking][:firewall][@family].each do |r| # ~FC034 -%>
<%= r[:action] %> <%= r[:source] %> <%= r[:dest] %> <%= r[:proto] %> <%= r[:dest_ports] %> <%= r[:source_ports] %> - <%= r[:rate_limit] %>
<% end -%>