class Facter::Resolvers::Cloud

Private Class Methods

detect_azure(fact_name) click to toggle source
# File lib/facter/resolvers/cloud.rb, line 16
def detect_azure(fact_name)
  search_dirs = %w[/var/lib/dhcp /var/lib/NetworkManager]
  search_dirs.each do |path|
    next if !File.readable?(path) || !File.directory?(path)

    files = Dir.entries(path)
    files.select! { |filename| filename =~ /^dhclient.*lease.*$/ }
    files.each do |file|
      path = File.join([path, file])
      output = Util::FileHelper.safe_read(path)

      if output.include?('option unknown-245') || output.include?('option 245')
        @fact_list[:cloud_provider] = 'azure'
        return @fact_list[fact_name]
      end
    end
  end
  nil
end
post_resolve(fact_name) click to toggle source
# File lib/facter/resolvers/cloud.rb, line 12
def post_resolve(fact_name)
  @fact_list.fetch(fact_name) { detect_azure(fact_name) }
end