diff --git a/libraries/default.rb b/libraries/default.rb
index <HASH>..<HASH> 100644
--- a/libraries/default.rb
+++ b/libraries/default.rb
@@ -112,6 +112,19 @@ class Chef
           end
         end
       end
+
+      def find_database_server(role)
+        dbm = find_matching_role(role)
+        Chef::Log.warn("No node with role #{role}") if role && !dbm
+
+        if respond_to?(:database) && database.has_key?('host')
+          database['host']
+        elsif dbm && dbm.attribute?('cloud')
+          dbm['cloud']['local_ipv4']
+        elsif dbm
+          dbm['ipaddress']
+        end
+      end
     end
   end
Factor out the logic to determine the actual database server; whether that comes from a search, or is manually specified. In particular, this makes it possible to specify a host that is not managed in chef, per COOK-<I>.

There is a bit of a layering violation here (not all respond to :database), but it just makes sense to share this code.