Puppet Function: dnsquery::soa

Defined in:
vendor_modules/dnsquery/lib/puppet/functions/dnsquery/soa.rb
Function type:
Ruby 4.x API

Overview

dnsquery::soa(Stdlib::Fqdn $question, Optional[Optional[Dnsquery::Config_info]] $config_info, Optional[Callable] &$block)Dnsquery::Soa

Retrieves DNS SOA records and returns it as a hash.

Parameters:

  • question (Stdlib::Fqdn)

    the dns question to lookup

  • config_info (Optional[Optional[Dnsquery::Config_info]])

    used to override the config for Resolve::DNS.new

  • &block (Optional[Callable])

    an optional lambda to return a default value in case the lookup fails

Returns:

  • (Dnsquery::Soa)

    The SOA record matching domain



6
7
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
# File 'vendor_modules/dnsquery/lib/puppet/functions/dnsquery/soa.rb', line 6

Puppet::Functions.create_function(:'dnsquery::soa') do
  # @param question the dns question to lookup
  # @param config_info used to override the config for Resolve::DNS.new
  # @param block an optional lambda to return a default value in case the lookup fails
  # @return The SOA record matching domain
  dispatch :dns_soa do
    param 'Stdlib::Fqdn', :question
    optional_param 'Optional[Dnsquery::Config_info]', :config_info
    optional_block_param :block
    return_type 'Dnsquery::Soa'
  end

  def dns_soa(question, config_info = nil)
    resolver = PuppetX::Voxpupuli::Dnsquery::Utils.resolver(config_info)
    res = resolver.getresource(
      question, Resolv::DNS::Resource::IN::SOA
    )
    {
      'expire'  => res.expire,
      'minimum' => res.minimum,
      'mname'   => res.mname.to_s,
      'refresh' => res.refresh,
      'retry'   => res.retry,
      'rname'   => res.rname.to_s,
      'serial'  => res.serial,
    }
  rescue Resolv::ResolvError
    block_given? ? yield : raise
  end
end