X-Git-Url: https://git.openstreetmap.org/chef.git/blobdiff_plain/faf8ae12e85eabb050b0f5eceb2cb67ad1de5261..69f0fad6138dc422bb01c60a2433c4f5687afe15:/cookbooks/networking/libraries/ipaddresses.rb?ds=sidebyside diff --git a/cookbooks/networking/libraries/ipaddresses.rb b/cookbooks/networking/libraries/ipaddresses.rb index 811c81884..67c89d052 100644 --- a/cookbooks/networking/libraries/ipaddresses.rb +++ b/cookbooks/networking/libraries/ipaddresses.rb @@ -4,22 +4,26 @@ class Chef addresses = [] interfaces(options).each do |interface| + address = interface[:public_address] || interface[:address] + + next if address.nil? + if block.nil? - addresses << interface[:address] + addresses << address else - block.call(interface[:address]) + yield address end end addresses end - def internal_ipaddress - return ipaddresses(:role => :internal).first + def internal_ipaddress(options = {}) + ipaddresses(options.merge(:role => :internal)).first end - def external_ipaddress - return ipaddresses(:role => :external).first + def external_ipaddress(options = {}) + ipaddresses(options.merge(:role => :external)).first end end end