Refactor data bag searches into library

This series of commits extracts the searches for data bags into a library to avoid repeated code.  It also avoids searches where possible by consulting a list of known data bags before searching.