Skip to content

Instantly share code, notes, and snippets.

@hunner
Created May 24, 2012 12:24
Show Gist options
  • Save hunner/2781280 to your computer and use it in GitHub Desktop.
Save hunner/2781280 to your computer and use it in GitHub Desktop.
facter
Facter.add("dbservers") do
setcode do
hosts = nil
if File.exists?('/etc/bookings/db.conf')
hosts = File.readlines('/etc/bookings/db.conf').collect do |line|
next if ! line.match(/dbi:mysql:/)
match = line.match(/host=([^;]+);/)
match[1] if match
end.compact.join(',')
end
hosts
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment