]> git.openstreetmap.org Git - chef.git/blob - cookbooks/networking/libraries/ipaddresses.rb
Add basic infrastructure for wireguard tunnels
[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
22       ipaddresses(:role => :internal).first
23     end
24
25     def external_ipaddress
26       ipaddresses(:role => :external).first
27     end
28   end
29 end