X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/3a4d52bd4c0f8e6ae7679145846b7bc7845d8ace..2ecb8ca90ac730ada6e083aebd8f3265033f46d5:/cookbooks/networking/libraries/interfaces.rb?ds=sidebyside diff --git a/cookbooks/networking/libraries/interfaces.rb b/cookbooks/networking/libraries/interfaces.rb index fa0a93c7d..c2f170b9c 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_value do |interface| - if options[:role].nil? || interface[:role].to_s == options[:role].to_s - if options[:family].nil? || interface[:family].to_s == options[:family].to_s - if block.nil? - interfaces << interface - else - block.call(interface) - end - end + 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 + yield interface end end