]> git.openstreetmap.org Git - chef.git/blob - cookbooks/networking/libraries/ipaddresses.rb
Don't try and update grub under test kitchen
[chef.git] / cookbooks / networking / libraries / ipaddresses.rb
1 class Chef
2   class Node
3     def ipaddresses(options = {}, &block)
4       addresses = []
5
6       interfaces(options).each do |interface|
7         address = interface[:public_address] || interface[:address]
8
9         next if address.nil?
10
11         if block.nil?
12           addresses << address
13         else
14           yield address
15         end
16       end
17
18       addresses
19     end
20
21     def internal_ipaddress(options = {})
22       ipaddresses(options.merge(:role => :internal)).first
23     end
24
25     def external_ipaddress(options = {})
26       ipaddresses(options.merge(:role => :external)).first
27     end
28   end
29 end