]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/networking/libraries/ipaddresses.rb
Add initial version of prometheus cookbook
[chef.git] / cookbooks / networking / libraries / ipaddresses.rb
index 811c81884387cbcd02cb7a5382bb123ccf35a93c..9fde5610be525b6a40bf91d8bb418e13f4e5e347 100644 (file)
@@ -4,10 +4,14 @@ 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
 
@@ -15,11 +19,11 @@ class Chef
     end
 
     def internal_ipaddress
-      return ipaddresses(:role => :internal).first
+      ipaddresses(:role => :internal).first
     end
 
     def external_ipaddress
-      return ipaddresses(:role => :external).first
+      ipaddresses(:role => :external).first
     end
   end
 end