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
25 default_action :nothing
27 property :rule, :kind_of => String, :name_property => true
28 property :family, :kind_of => [String, Symbol]
29 property :source, :kind_of => String, :required => true
30 property :dest, :kind_of => String, :required => true
31 property :proto, :kind_of => String, :required => true
32 property :dest_ports, :kind_of => [String, Integer], :default => "-"
33 property :source_ports, :kind_of => [String, Integer], :default => "-"
34 property :rate_limit, :kind_of => String, :default => "-"
35 property :connection_limit, :kind_of => [String, Integer], :default => "-"
36 property :helper, :kind_of => String, :default => "-"
38 property :compile_time, TrueClass, :default => true
55 :action => action.to_s.upcase,
56 :source => new_resource.source,
57 :dest => new_resource.dest,
58 :proto => new_resource.proto,
59 :dest_ports => new_resource.dest_ports.to_s,
60 :source_ports => new_resource.source_ports.to_s,
61 :rate_limit => new_resource.rate_limit,
62 :connection_limit => new_resource.connection_limit.to_s,
63 :helper => new_resource.helper
66 if new_resource.family.nil?
67 node.default[:networking][:firewall][:inet] << rule
68 node.default[:networking][:firewall][:inet6] << rule
69 elsif new_resource.family.to_s == "inet"
70 node.default[:networking][:firewall][:inet] << rule
71 elsif new_resource.family.to_s == "inet6"
72 node.default[:networking][:firewall][:inet6] << rule
74 log "Unsupported network family" do