Module: Puppet::Network::Resolver
- Defined in:
- lib/puppet/network/resolver.rb
Class Method Summary collapse
-
.each_srv_record(domain, service_name = :puppet, &block) ⇒ Object
Iterate through the list of servers that service this hostname and yield each server/port since SRV records have ports in them It will override whatever masterport setting is already set.
Class Method Details
.each_srv_record(domain, service_name = :puppet, &block) ⇒ Object
Iterate through the list of servers that service this hostname and yield each server/port since SRV records have ports in them It will override whatever masterport setting is already set.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/puppet/network/resolver.rb', line 8 def self.each_srv_record(domain, service_name = :puppet, &block) if (domain.nil? or domain.empty?) Puppet.debug "Domain not known; skipping SRV lookup" return end Puppet.debug "Searching for SRV records for domain: #{domain}" case service_name when :puppet then service = '_x-puppet' when :ca then service = '_x-puppet-ca' when :report then service = '_x-puppet-report' when :file then service = '_x-puppet-fileserver' else service = "_x-puppet-#{service_name.to_s}" end srv_record = "#{service}._tcp.#{domain}" resolver = Resolv::DNS.new records = resolver.getresources(srv_record, Resolv::DNS::Resource::IN::SRV) Puppet.debug "Found #{records.size} SRV records for: #{srv_record}" if records.size == 0 && service_name != :puppet # Try the generic :puppet service if no SRV records were found # for the specific service. each_srv_record(domain, :puppet, &block) else each_priority(records) do |priority, recs| while next_rr = recs.delete(find_weighted_server(recs)) Puppet.debug "Yielding next server of #{next_rr.target.to_s}:#{next_rr.port}" yield next_rr.target.to_s, next_rr.port end end end end |