Skip to content

Commit

Permalink
Move create_rule() to core library and rename it AFW
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Vehent committed Oct 2, 2012
1 parent 9aaab36 commit fe6bc60
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
19 changes: 18 additions & 1 deletion libraries/core.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module AFWCore
module AFW

# IP dummy regex, from `0.0.0.0` to `999.999.999.999`
IP_CIDR_VALID_REGEX = /\b(?:\d{1,3}\.){3}\d{1,3}\b(\/[0-3]?[0-9])?/
Expand Down Expand Up @@ -385,4 +385,21 @@ def build_rule_array(iptables_header, sources, destinations)

return iptables_array_destination
end


#
# Exported to other cookbooks ----
#
module_function
extend self
def create_rule(node, name, params)
node['afw']['rules'][name] = params
# Wrapper around `process_rule`
#
Chef::Log.info("AFW.create_rule(): processing '#{name}'")
if AFW.process_rule(node, name, params)
Chef::Log.info("AFW.create_rule(): finished processing '#{name}'")
end
return true
end
end
15 changes: 0 additions & 15 deletions libraries/create_rule.rb

This file was deleted.

2 changes: 1 addition & 1 deletion metadata.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
node['afw']['tables']['nat']['chains'] = []

class Chef::Recipe
include AFWCore
include AFW
end

node['afw']['rules'].each do |name,params|
Expand Down

0 comments on commit fe6bc60

Please sign in to comment.