summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
3c8daa0)
Instead of patching the variables attached to the resource, keep
the list of firewall rules in the attributes.
+default[:networking][:firewall][:inet] = []
+default[:networking][:firewall][:inet6] = []
default[:networking][:interfaces] = {}
default[:networking][:nameservers] = []
default[:networking][:search] = []
default[:networking][:interfaces] = {}
default[:networking][:nameservers] = []
default[:networking][:search] = []
#
define :firewall_rule, :action => :accept do
#
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],
rule = Hash[
:action => params[:action].to_s.upcase,
:source => params[:source],
]
if params[:family].nil?
]
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"
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"
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
else
log "Unsupported network family" do
level :error
owner "root"
group "root"
mode 0o644
owner "root"
group "root"
mode 0o644
+ variables :family => "inet"
notifies :restart, "service[shorewall]"
end
notifies :restart, "service[shorewall]"
end
owner "root"
group "root"
mode 0o644
owner "root"
group "root"
mode 0o644
+ variables :family => "inet6"
notifies :restart, "service[shorewall6]"
end
notifies :restart, "service[shorewall6]"
end
# ACTION SOURCE DEST PROTO DEST SOURCE ORIGINAL RATE
# PORTS PORTS DEST LIMIT
# 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 -%>
<%= r[:action] %> <%= r[:source] %> <%= r[:dest] %> <%= r[:proto] %> <%= r[:dest_ports] %> <%= r[:source_ports] %> - <%= r[:rate_limit] %>
<% end -%>