]> review.fuel-infra Code Review - puppet-modules/puppetlabs-firewall.git/commitdiff
Make rsource, rdest, reap and rttl known_booleans and remove munging.
authorStephen Grier <git@grier.org.uk>
Mon, 30 Sep 2013 00:23:27 +0000 (01:23 +0100)
committerHunter Haugen <hunter@puppetlabs.com>
Tue, 4 Feb 2014 23:26:48 +0000 (15:26 -0800)
lib/puppet/provider/firewall/ip6tables.rb
lib/puppet/provider/firewall/iptables.rb
lib/puppet/type/firewall.rb

index 3055d08c41bd4c0061b4b7ba85330e04763488e3..cc8ad61a4abb7ef25e3198467733dde27f54feb2 100644 (file)
@@ -78,7 +78,7 @@ Puppet::Type.type(:firewall).provide :ip6tables, :parent => :iptables, :source =
 
   # These are known booleans that do not take a value, but we want to munge
   # to true if they exist.
-  @known_booleans = [:ishasmorefrags, :islastfrag, :isfirstfrag]
+  @known_booleans = [:ishasmorefrags, :islastfrag, :isfirstfrag, :rsource, :rdest, :reap, :rttl]
 
   # Create property methods dynamically
   (@resource_map.keys << :chain << :table << :action).each do |property|
index 63b75fab6d066011d9d2df4dce35da1a10d82ccd..a6df9c56eefc8496469c21e15569230611f35d8d 100644 (file)
@@ -92,7 +92,7 @@ Puppet::Type.type(:firewall).provide :iptables, :parent => Puppet::Provider::Fir
 
   # These are known booleans that do not take a value, but we want to munge
   # to true if they exist.
-  @known_booleans = [:socket, :isfragment]
+  @known_booleans = [:socket, :isfragment, :rsource, :rdest, :reap, :rttl]
 
 
   # Create property methods dynamically
@@ -202,12 +202,6 @@ Puppet::Type.type(:firewall).provide :iptables, :parent => Puppet::Provider::Fir
     # the actual rule will have the ! mark before the option.
     values = values.sub(/(!)\s*(-\S+)\s*(\S*)/, '\2 "\1 \3"')
 
-    # rsource, rdest, reap and rttl take no values. Cheat by adding "" after them.
-    values = values.sub(/--rsource/, '--rsource ""')
-    values = values.sub(/--rdest/, '--rdest ""')
-    values = values.sub(/--reap/, '--reap ""')
-    values = values.sub(/--rttl/, '--rttl ""')
-
     # Trick the system for booleans
     @known_booleans.each do |bool|
       # append "true" because all params are expected to have values
@@ -387,18 +381,6 @@ Puppet::Type.type(:firewall).provide :iptables, :parent => Puppet::Provider::Fir
             next
           end
         end
-        if res == :rsource then
-          resource_value = nil
-        end
-        if res == :rdest then
-          resource_value = nil
-        end
-        if res == :reap then
-          resource_value = nil
-        end
-        if res == :rttl then
-          resource_value = nil
-        end
       elsif res == :jump and resource[:action] then
         # In this case, we are substituting jump for action
         resource_value = resource[:action].to_s.upcase
index 7ef0cf00d8040d38f73b123c905ee5f107319265..b7f2deb817b704bf5261ed3e03e7100ae041e7ea 100644 (file)
@@ -698,7 +698,12 @@ Puppet::Type.newtype(:firewall) do
   newproperty(:recent, :required_features => :recent_limiting) do
     desc <<-EOS
       Enable the recent module. Takes as an argument one of set, update,
-      rcheck or remove.
+      rcheck or remove. For example:
+
+          recent => 'update',
+          rseconds => 60,
+          rhitcount => 4,
+          rsource => true,
     EOS
 
     newvalues(:set, :update, :rcheck, :remove)
@@ -710,14 +715,14 @@ Puppet::Type.newtype(:firewall) do
   newproperty(:rdest, :required_features => :recent_limiting) do
     desc <<-EOS
       Recent module; add the destination IP address to the list.
-      Takes no argument.
+      Must be boolean true.
     EOS
   end
 
   newproperty(:rsource, :required_features => :recent_limiting) do
     desc <<-EOS
       Recent module; add the source IP address to the list.
-      Takes no argument.
+      Must be boolean true.
     EOS
   end
 
@@ -740,6 +745,7 @@ Puppet::Type.newtype(:firewall) do
     desc <<-EOS
       Recent module; can only be used in conjunction with --seconds. When
       used, this will cause entries older then 'seconds' to be purged.
+      Must be boolean true.
     EOS
   end
 
@@ -761,6 +767,7 @@ Puppet::Type.newtype(:firewall) do
       useful if you have problems with people faking their source
       address in order to DoS you via this module by disallowing others
       access to your site by sending bogus packets to you.
+      Must be boolean true.
     EOS
   end