Sha256: 91c441e072070b3cb4c7a2e77808acfd2d62bc580f6d1d964b7929a538212922

Contents?: true

Size: 1.16 KB

Versions: 14

Compression:

Stored size: 1.16 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 => @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
    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

14 entries across 14 versions & 1 rubygems

Version Path
puppet-3.4.3 lib/puppet/configurer/fact_handler.rb
puppet-3.4.2 lib/puppet/configurer/fact_handler.rb
puppet-3.4.1 lib/puppet/configurer/fact_handler.rb
puppet-3.4.0 lib/puppet/configurer/fact_handler.rb
puppet-3.4.0.rc2 lib/puppet/configurer/fact_handler.rb
puppet-3.4.0.rc1 lib/puppet/configurer/fact_handler.rb
puppet-3.3.2 lib/puppet/configurer/fact_handler.rb
puppet-3.3.1 lib/puppet/configurer/fact_handler.rb
puppet-3.3.1.rc3 lib/puppet/configurer/fact_handler.rb
puppet-3.3.1.rc2 lib/puppet/configurer/fact_handler.rb
puppet-3.3.1.rc1 lib/puppet/configurer/fact_handler.rb
puppet-3.3.0 lib/puppet/configurer/fact_handler.rb
puppet-3.3.0.rc3 lib/puppet/configurer/fact_handler.rb
puppet-3.3.0.rc2 lib/puppet/configurer/fact_handler.rb