X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/faf8ae12e85eabb050b0f5eceb2cb67ad1de5261..eb1f896a0237db83aa4cf3c2ecd9a9a77e681fda:/cookbooks/networking/libraries/interfaces.rb diff --git a/cookbooks/networking/libraries/interfaces.rb b/cookbooks/networking/libraries/interfaces.rb index cc9c11a23..029cb4f32 100644 --- a/cookbooks/networking/libraries/interfaces.rb +++ b/cookbooks/networking/libraries/interfaces.rb @@ -4,17 +4,16 @@ class Chef interfaces = [] networking = construct_attributes[:networking] || {} - networking_interfaces = networking[:interfaces] || [] + 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 + networking_interfaces.each_value do |interface| + next unless options[:role].nil? || interface[:role].to_s == options[:role].to_s + next unless options[:family].nil? || interface[:family].to_s == options[:family].to_s + + if block.nil? + interfaces << interface + else + block.call(interface) end end