X-Git-Url: https://git.openstreetmap.org/chef.git/blobdiff_plain/2ec62d46e6d050fe6384df90a2869036662d1b51..faf8ae12e85eabb050b0f5eceb2cb67ad1de5261:/cookbooks/networking/libraries/interfaces.rb diff --git a/cookbooks/networking/libraries/interfaces.rb b/cookbooks/networking/libraries/interfaces.rb new file mode 100644 index 000000000..cc9c11a23 --- /dev/null +++ b/cookbooks/networking/libraries/interfaces.rb @@ -0,0 +1,24 @@ +class Chef + class Node + def interfaces(options = {}, &block) + interfaces = [] + + networking = construct_attributes[:networking] || {} + networking_interfaces = networking[:interfaces] || [] + + networking_interfaces.each do |name,interface| + if options[:role].nil? or interface[:role].to_s == options[:role].to_s + if options[:family].nil? or interface[:family].to_s == options[:family].to_s + if block.nil? + interfaces << interface + else + block.call(interface) + end + end + end + end + + interfaces + end + end +end