2 # Cookbook:: networking
 
   3 # Resource:: firewall_rule
 
   5 # Copyright:: 2020, OpenStreetMap Foundation
 
   7 # Licensed under the Apache License, Version 2.0 (the "License");
 
   8 # you may not use this file except in compliance with the License.
 
   9 # You may obtain a copy of the License at
 
  11 #     https://www.apache.org/licenses/LICENSE-2.0
 
  13 # Unless required by applicable law or agreed to in writing, software
 
  14 # distributed under the License is distributed on an "AS IS" BASIS,
 
  15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16 # See the License for the specific language governing permissions and
 
  17 # limitations under the License.
 
  20 resource_name :firewall_rule
 
  21 provides :firewall_rule
 
  23 default_action :nothing
 
  25 property :rule, :kind_of => String, :name_property => true
 
  26 property :family, :kind_of => [String, Symbol]
 
  27 property :source, :kind_of => String, :required => true
 
  28 property :dest, :kind_of => String, :required => true
 
  29 property :proto, :kind_of => String, :required => true
 
  30 property :dest_ports, :kind_of => [String, Integer], :default => "-"
 
  31 property :source_ports, :kind_of => [String, Integer], :default => "-"
 
  32 property :rate_limit, :kind_of => String, :default => "-"
 
  33 property :connection_limit, :kind_of => [String, Integer], :default => "-"
 
  34 property :helper, :kind_of => String, :default => "-"
 
  51       :action => action.to_s.upcase,
 
  52       :source => new_resource.source,
 
  53       :dest => new_resource.dest,
 
  54       :proto => new_resource.proto,
 
  55       :dest_ports => new_resource.dest_ports.to_s,
 
  56       :source_ports => new_resource.source_ports.to_s,
 
  57       :rate_limit => new_resource.rate_limit,
 
  58       :connection_limit => new_resource.connection_limit.to_s,
 
  59       :helper => new_resource.helper
 
  62     if new_resource.family.nil?
 
  63       node.default[:networking][:firewall][:inet] << rule
 
  64       node.default[:networking][:firewall][:inet6] << rule
 
  65     elsif new_resource.family.to_s == "inet"
 
  66       node.default[:networking][:firewall][:inet] << rule
 
  67     elsif new_resource.family.to_s == "inet6"
 
  68       node.default[:networking][:firewall][:inet6] << rule
 
  70       log "Unsupported network family" do