Sha256: cbf34fd772e402202f4d31326b5a06359b9d2fba7469ad41bfc7910d129bc711

Contents?: true

Size: 574 Bytes

Versions: 5

Compression:

Stored size: 574 Bytes

Contents

# frozen_string_literal: true

module Facts
  module Linux
    class Ec2Metadata
      FACT_NAME = 'ec2_metadata'

      def initialize
        @virtual = Facter::VirtualDetector.new
      end

      def call_the_resolver
        return Facter::ResolvedFact.new(FACT_NAME, nil) unless aws_hypervisors?

        fact_value = Facter::Resolvers::Ec2.resolve(:metadata)

        Facter::ResolvedFact.new(FACT_NAME, fact_value&.empty? ? nil : fact_value)
      end

      private

      def aws_hypervisors?
        @virtual.platform =~ /kvm|xen|aws/
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
facter-4.0.46 lib/facter/facts/linux/ec2_metadata.rb
facter-4.0.44 lib/facter/facts/linux/ec2_metadata.rb
facter-4.0.43 lib/facter/facts/linux/ec2_metadata.rb
facter-4.0.42 lib/facter/facts/linux/ec2_metadata.rb
facter-4.0.41 lib/facter/facts/linux/ec2_metadata.rb