nslookup_txt_records

in chef/cookbooks/uber_helpers/libraries/node_utils.rb [941:966]


    def nslookup_txt_records(domain, timeout = 3)
      results = {}
      unless macos?
        Chef::Log.warn('node.nslookup called on non-OS X!')
        return nil
      end
      records = shell_out(
        "/usr/bin/nslookup -type=txt #{domain} -timeout=#{timeout}",
      ).run_command.stdout.to_s.scan(/text = "(.*)"/).flatten
      records.each do |line|
        if domain == 'debug.opendns.com'
          if line.include?('flags') || line.include?('dnscrypt')
            split_line = line.split(' ', 2)
            results[split_line[0]] = split_line[1]
          else
            split_line = line.rpartition(' ')
            results[split_line.first] = split_line.last
          end
        else
          split_line = line.rpartition(' ')
          results[split_line.first] = split_line.last
        end
      end
      results
    end