Sha256: 79fc17ede557dbda11498ba19554b5418cabbc41c56a11f204bf3cb17b95d6eb
Contents?: true
Size: 1.02 KB
Versions: 6
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true module Facter module Resolvers class Cloud < BaseResolver # cloud_provider @fact_list ||= {} class << self private def post_resolve(fact_name) @fact_list.fetch(fact_name) { detect_azure(fact_name) } end 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 end end end end
Version data entries
6 entries across 6 versions & 1 rubygems