Class: Chef::SslCertificateCookbook::AttributeHelpers

Inherits:
Object
  • Object
show all
Defined in:
libraries/attribute_helpers.rb

Overview

Helper methods to use from attribute files.

Usage example:

# attributes/whatever.rb
Chef::SslCertificateCookbook::AttributeHelpers.resolvers
  #=> "8.8.8.8:53"

Class Method Summary collapse

Class Method Details

.resolversString?

Returns the system DNS resolvers separated by spaces.

Examples:

resolvers #=> "8.8.8.8:53 4.4.4.2:53"

42
43
44
45
46
47
# File 'libraries/attribute_helpers.rb', line 42

def self.resolvers
  empty_ary = [nil, [], [[]], [['0.0.0.0', 53]]]
  resolvers = Resolv::DNS::Config.new.lazy_initialize.nameserver_port
  return nil if empty_ary.include?(resolvers)
  resolvers.map { |x| x.join(':') }.join(' ')
end