Sha256: 7ba6792be5903eaf357209f04928e688452632b0b1bb3c427f5a7fb6b4d92e0e

Contents?: true

Size: 1.66 KB

Versions: 27

Compression:

Stored size: 1.66 KB

Contents

require 'puppet/indirector/facts/facter'

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 download_fact_plugins?
    Puppet[:factsync]
  end

  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])
      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
      puts detail.backtrace if Puppet[:trace]
      raise Puppet::Error, "Could not retrieve local facts: #{detail}"
    end
  end

  def facts_for_uploading
    facts = find_facts
    #format = facts.class.default_format

    if facts.support_format?(:b64_zlib_yaml)
      format = :b64_zlib_yaml
    else
      format = :yaml
    end

    text = facts.render(format)

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

  # Retrieve facts from the central server.
  def download_fact_plugins
    return unless download_fact_plugins?

    # Deprecated prior to 0.25, as of 5/19/2008
    Puppet.warning "Fact syncing is deprecated as of 0.25 -- use 'pluginsync' instead"

    Puppet::Configurer::Downloader.new("fact", Puppet[:factdest], Puppet[:factsource], Puppet[:factsignore]).evaluate
  end
end

Version data entries

27 entries across 27 versions & 3 rubygems

Version Path
puppet-parse-0.1.4 lib/vendor/puppet/configurer/fact_handler.rb
puppet-parse-0.1.3 lib/vendor/puppet/configurer/fact_handler.rb
puppet-parse-0.1.2 lib/vendor/puppet/configurer/fact_handler.rb
puppet-parse-0.1.1 lib/vendor/puppet/configurer/fact_handler.rb
puppet-2.7.26 lib/puppet/configurer/fact_handler.rb
puppet-2.7.25 lib/puppet/configurer/fact_handler.rb
puppet-2.7.24 lib/puppet/configurer/fact_handler.rb
puppet-2.7.23 lib/puppet/configurer/fact_handler.rb
puppet-2.7.22 lib/puppet/configurer/fact_handler.rb
puppet-parse-0.1.0 lib/vendor/puppet/configurer/fact_handler.rb
puppet-parse-0.0.6 lib/vendor/puppet/configurer/fact_handler.rb
puppet-2.7.21 lib/puppet/configurer/fact_handler.rb
puppet-parse-0.0.5 lib/vendor/puppet/configurer/fact_handler.rb
puppet-parse-0.0.4 lib/vendor/puppet/configurer/fact_handler.rb
puppet-parse-0.0.2 lib/vendor/puppet/configurer/fact_handler.rb
puppet-2.7.20 lib/puppet/configurer/fact_handler.rb
puppet-2.7.20.rc1 lib/puppet/configurer/fact_handler.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/lib/puppet/configurer/fact_handler.rb
puppet-2.7.19 lib/puppet/configurer/fact_handler.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/lib/puppet/configurer/fact_handler.rb