Sha256: 6a7622ea9c4e5fe34619278210135501d1c55569dcb74135ceb121abc374a6bf

Contents?: true

Size: 1.64 KB

Versions: 20

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

#
# @api private
# Default Facter implementation that delegates to Facter API
#

module Puppet
  class FacterImpl
    def initialize
      require 'facter'

      setup_logging
    end

    def value(fact_name)
      ::Facter.value(fact_name)
    end

    def add(name, &block)
      ::Facter.add(name, &block)
    end

    def to_hash
      ::Facter.to_hash
    end

    def clear
      ::Facter.clear
    end

    def reset
      ::Facter.reset
    end

    def resolve(options)
      ::Facter.resolve(options)
    end

    def search_external(dirs)
      ::Facter.search_external(dirs)
    end

    def search(*dirs)
      ::Facter.search(*dirs)
    end

    def trace(value)
      ::Facter.trace(value) if ::Facter.respond_to? :trace
    end

    def debugging(value)
      ::Facter.debugging(value) if ::Facter.respond_to?(:debugging)
    end

    def load_external?
      ::Facter.respond_to?(:load_external)
    end

    def load_external(value)
      ::Facter.load_external(value) if load_external?
    end

    private

    def setup_logging
      return unless ::Facter.respond_to? :on_message

      ::Facter.on_message do |level, message|
        case level
        when :trace, :debug
          level = :debug
        when :info
          # Same as Puppet
        when :warn
          level = :warning
        when :error
          level = :err
        when :fatal
          level = :crit
        else
          next
        end

        Puppet::Util::Log.create(
          {
            :level => level,
            :source => 'Facter',
            :message => message
          }
        )
        nil
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-8.10.0 lib/puppet/facter_impl.rb
puppet-8.10.0-x86-mingw32 lib/puppet/facter_impl.rb
puppet-8.10.0-x64-mingw32 lib/puppet/facter_impl.rb
puppet-8.10.0-universal-darwin lib/puppet/facter_impl.rb
puppet-8.9.0 lib/puppet/facter_impl.rb
puppet-8.9.0-x86-mingw32 lib/puppet/facter_impl.rb
puppet-8.9.0-x64-mingw32 lib/puppet/facter_impl.rb
puppet-8.9.0-universal-darwin lib/puppet/facter_impl.rb
puppet-8.8.1 lib/puppet/facter_impl.rb
puppet-8.8.1-x86-mingw32 lib/puppet/facter_impl.rb
puppet-8.8.1-x64-mingw32 lib/puppet/facter_impl.rb
puppet-8.8.1-universal-darwin lib/puppet/facter_impl.rb
puppet-8.7.0 lib/puppet/facter_impl.rb
puppet-8.7.0-x86-mingw32 lib/puppet/facter_impl.rb
puppet-8.7.0-x64-mingw32 lib/puppet/facter_impl.rb
puppet-8.7.0-universal-darwin lib/puppet/facter_impl.rb
puppet-8.6.0 lib/puppet/facter_impl.rb
puppet-8.6.0-x86-mingw32 lib/puppet/facter_impl.rb
puppet-8.6.0-x64-mingw32 lib/puppet/facter_impl.rb
puppet-8.6.0-universal-darwin lib/puppet/facter_impl.rb