X-Git-Url: https://git.openstreetmap.org/chef.git/blobdiff_plain/2ec62d46e6d050fe6384df90a2869036662d1b51..faf8ae12e85eabb050b0f5eceb2cb67ad1de5261:/cookbooks/networking/libraries/ipaddresses.rb diff --git a/cookbooks/networking/libraries/ipaddresses.rb b/cookbooks/networking/libraries/ipaddresses.rb new file mode 100644 index 000000000..811c81884 --- /dev/null +++ b/cookbooks/networking/libraries/ipaddresses.rb @@ -0,0 +1,25 @@ +class Chef + class Node + def ipaddresses(options = {}, &block) + addresses = [] + + interfaces(options).each do |interface| + if block.nil? + addresses << interface[:address] + else + block.call(interface[:address]) + end + end + + addresses + end + + def internal_ipaddress + return ipaddresses(:role => :internal).first + end + + def external_ipaddress + return ipaddresses(:role => :external).first + end + end +end