Created
August 7, 2010 12:24
-
-
Save anonymous/512755 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Facter.add("loghost_list") do | |
require 'resolv' | |
soas = [] | |
loghosts = [] | |
domain = Facter.value( :domain ) | |
res = Resolv::DNS::new('/etc/resolv.conf') | |
nameservers = res.getresources( domain, Resolv::DNS::Resource::IN::NS) | |
nameservers.each { |x| soas.push(Resolv.getaddress(x.name.to_s) ) } | |
ares = Resolv::DNS::new( { :nameserver => soas, :search => [ domain ], :ndots => 1 } ) | |
ares.each_resource(['loghost',domain].join('.'), Resolv::DNS::Resource::IN::ANY) do |r| | |
if r.kind_of?(Resolv::DNS::Resource::IN::A) then | |
loghosts.push(r.name.to_s) | |
elsif r.kind_of?(Resolv::DNS::Resource::CNAME) then | |
loghosts.push(r.name.to_s) | |
end | |
end | |
loghost_list=loghosts.join(":"); | |
if loghost | |
loghost | |
else | |
nil | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment