X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/f30f230da23603e3c7598205219ce01e9820c470..d4c5d678a0c6702d8a49d1d2a76f4c215decae03:/cookbooks/networking/libraries/ipaddresses.rb diff --git a/cookbooks/networking/libraries/ipaddresses.rb b/cookbooks/networking/libraries/ipaddresses.rb index 51ef152b5..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 - yield interface[:address] + yield address end end addresses end - def internal_ipaddress - ipaddresses(:role => :internal).first + def internal_ipaddress(options = {}) + ipaddresses(options.merge(:role => :internal)).first end - def external_ipaddress - ipaddresses(:role => :external).first + def external_ipaddress(options = {}) + ipaddresses(options.merge(:role => :external)).first end end end