Sha256: 5fef53593e70ceb198b23f4a2a65e96e0eeba1cf79e37059f85eb1ac3274fabb

Contents?: true

Size: 1.21 KB

Versions: 128

Compression:

Stored size: 1.21 KB

Contents

require 'puppet/indirector/facts/facter'

require 'puppet/configurer'
require 'puppet/configurer/downloader'

# Break out the code related to facts.  This module is
# just included into the agent, but having it here makes it
# easier to test.
module Puppet::Configurer::FactHandler
  def find_facts
    # This works because puppet agent configures Facts to use 'facter' for
    # finding facts and the 'rest' terminus for caching them.  Thus, we'll
    # compile them and then "cache" them on the server.
    begin
      facts = Puppet::Node::Facts.indirection.find(Puppet[:node_name_value], :environment => Puppet::Node::Environment.remote(@environment))
      unless Puppet[:node_name_fact].empty?
        Puppet[:node_name_value] = facts.values[Puppet[:node_name_fact]]
        facts.name = Puppet[:node_name_value]
      end
      facts
    rescue SystemExit,NoMemoryError
      raise
    rescue Exception => detail
      message = "Could not retrieve local facts: #{detail}"
      Puppet.log_exception(detail, message)
      raise Puppet::Error, message, detail.backtrace
    end
  end

  def facts_for_uploading
    facts = find_facts

    text = facts.render(:pson)

    {:facts_format => :pson, :facts => CGI.escape(text)}
  end
end

Version data entries

128 entries across 128 versions & 2 rubygems

Version Path
puppet-retrospec-1.5.0 vendor/gems/puppet-4.5.2/lib/puppet/configurer/fact_handler.rb
puppet-4.10.4 lib/puppet/configurer/fact_handler.rb
puppet-4.10.4-x86-mingw32 lib/puppet/configurer/fact_handler.rb
puppet-4.10.4-x64-mingw32 lib/puppet/configurer/fact_handler.rb
puppet-4.10.4-universal-darwin lib/puppet/configurer/fact_handler.rb
puppet-retrospec-1.4.1 vendor/gems/puppet-4.5.2/lib/puppet/configurer/fact_handler.rb
puppet-4.10.1 lib/puppet/configurer/fact_handler.rb
puppet-4.10.1-x86-mingw32 lib/puppet/configurer/fact_handler.rb
puppet-4.10.1-x64-mingw32 lib/puppet/configurer/fact_handler.rb
puppet-4.10.1-universal-darwin lib/puppet/configurer/fact_handler.rb
puppet-retrospec-1.4.0 vendor/gems/puppet-4.5.2/lib/puppet/configurer/fact_handler.rb
puppet-4.10.0 lib/puppet/configurer/fact_handler.rb
puppet-4.10.0-x86-mingw32 lib/puppet/configurer/fact_handler.rb
puppet-4.10.0-x64-mingw32 lib/puppet/configurer/fact_handler.rb
puppet-4.10.0-universal-darwin lib/puppet/configurer/fact_handler.rb
puppet-retrospec-1.3.2 vendor/gems/puppet-4.5.2/lib/puppet/configurer/fact_handler.rb
puppet-4.9.4 lib/puppet/configurer/fact_handler.rb
puppet-4.9.4-x86-mingw32 lib/puppet/configurer/fact_handler.rb
puppet-4.9.4-x64-mingw32 lib/puppet/configurer/fact_handler.rb
puppet-4.9.4-universal-darwin lib/puppet/configurer/fact_handler.rb