Autorequire Firewallchain resources for Firewall resources that have jump or
chain parameters. Remove require params from README examples now that
they're not essential.
Only deals with iptables and ip6tables providers, which have support for
chains. Doesn't attempt to weed out chains that might be builtin. Just let
Puppet determine which of the resources are really managed.
firewall { '100 forward to MY_CHAIN':
chain => 'INPUT',
jump => 'MY_CHAIN',
- require => Firewallchain["MY_CHAIN:filter:IPv4"],
}
# The namevar here is in the format chain_name:table:protocol
firewallchain { 'MY_CHAIN:filter:IPv4':
action => 'accept',
proto => 'tcp',
dport => 5000,
- require => Firewallchain["MY_CHAIN:filter:IPv4"],
}
You can make firewall rules persistent with the following iptables example:
EOS
end
+ autorequire(:firewallchain) do
+ case value(:provider)
+ when :iptables
+ protocol = "IPv4"
+ when :ip6tables
+ protocol = "IPv6"
+ else
+ return
+ end
+
+ reqs = []
+ [value(:chain), value(:jump)].each do |chain|
+ reqs << "#{chain}:#{value(:table)}:#{protocol}" unless chain.nil?
+ end
+
+ reqs
+ end
+
validate do
debug("[validate]")