summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-04-11 13:01:42 -0500
committerLuke Kanies <luke@madstop.com>2008-04-11 13:01:42 -0500
commitfb05ef3c96038d67a46eb142202af186ad6cb0b3 (patch)
tree148e8b882e5c8104c4f3fa8ecc4288e8608f812d /lib/puppet/network
parentb49fb68f768e8b98c555ef0ae08a7bd22f5d36bd (diff)
parentb49fd495622b15f96faf944db1e70cbe9e7fe7c4 (diff)
downloadpuppet-fb05ef3c96038d67a46eb142202af186ad6cb0b3.tar.gz
puppet-fb05ef3c96038d67a46eb142202af186ad6cb0b3.tar.xz
puppet-fb05ef3c96038d67a46eb142202af186ad6cb0b3.zip
Merge branch '0.24.x'
Diffstat (limited to 'lib/puppet/network')
-rw-r--r--lib/puppet/network/client/master.rb58
-rw-r--r--lib/puppet/network/handler/configuration.rb184
-rw-r--r--lib/puppet/network/handler/master.rb21
-rw-r--r--lib/puppet/network/xmlrpc/client.rb5
4 files changed, 11 insertions, 257 deletions
diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb
index 4c7fa5f5b..a2b6499bb 100644
--- a/lib/puppet/network/client/master.rb
+++ b/lib/puppet/network/client/master.rb
@@ -49,6 +49,8 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
end
# Return the list of dynamic facts as an array of symbols
+ # NOTE:LAK(2008/04/10): This code is currently unused, since we now always
+ # recompile.
def self.dynamic_facts
# LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
x = Puppet.settings[:dynamicfacts].split(/\s*,\s*/).collect { |fact| fact.downcase }
@@ -96,31 +98,6 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
end
end
- # Check whether our catalog is up to date
- def fresh?(facts)
- if Puppet[:ignorecache]
- Puppet.notice "Ignoring cache"
- return false
- end
- unless self.compile_time
- Puppet.debug "No cached compile time"
- return false
- end
- if facts_changed?(facts)
- Puppet.info "Facts have changed; recompiling" unless local?
- return false
- end
-
- newcompile = @driver.freshness
- # We're willing to give a 2 second drift
- if newcompile - @compile_time.to_i < 1
- return true
- else
- Puppet.debug "Server compile time is %s vs %s" % [newcompile, @compile_time.to_i]
- return false
- end
- end
-
# Let the daemon run again, freely in the filesystem. Frolick, little
# daemon!
def enable
@@ -147,11 +124,6 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
# Retrieve the plugins.
getplugins() if Puppet[:pluginsync]
- if (self.catalog or FileTest.exist?(self.cachefile)) and self.fresh?(facts)
- Puppet.info "Configuration is up to date"
- return if use_cached_config
- end
-
Puppet.debug("Retrieving catalog")
# If we can't retrieve the catalog, just return, which will either
@@ -450,32 +422,6 @@ class Puppet::Network::Client::Master < Puppet::Network::Client
loadfacts()
- # Have the facts changed since we last compiled?
- def facts_changed?(facts)
- oldfacts = (Puppet::Util::Storage.cache(:configuration)[:facts] || {}).dup
- newfacts = facts.dup
- self.class.dynamic_facts.each do |fact|
- [oldfacts, newfacts].each do |facthash|
- facthash.delete(fact) if facthash.include?(fact)
- end
- end
-
- if oldfacts == newfacts
- return false
- else
-# unless oldfacts
-# puts "no old facts"
-# return true
-# end
-# newfacts.keys.each do |k|
-# unless newfacts[k] == oldfacts[k]
-# puts "%s: %s vs %s" % [k, newfacts[k], oldfacts[k]]
-# end
-# end
- return true
- end
- end
-
# Actually retrieve the catalog, either from the server or from a
# local master.
def get_actual_config(facts)
diff --git a/lib/puppet/network/handler/configuration.rb b/lib/puppet/network/handler/configuration.rb
deleted file mode 100644
index 8168ce1d5..000000000
--- a/lib/puppet/network/handler/configuration.rb
+++ /dev/null
@@ -1,184 +0,0 @@
-require 'openssl'
-require 'puppet'
-require 'puppet/parser/interpreter'
-require 'puppet/sslcertificates'
-require 'xmlrpc/server'
-require 'yaml'
-
-class Puppet::Network::Handler
- class Configuration < Handler
- desc "Puppet's configuration compilation interface. Passed a node name
- or other key, retrieves information about the node (using the ``node_source``)
- and returns a compiled configuration."
-
- include Puppet::Util
-
- attr_accessor :local, :classes
-
- @interface = XMLRPC::Service::Interface.new("configuration") { |iface|
- iface.add_method("string configuration(string)")
- iface.add_method("string version()")
- }
-
- # Compile a node's configuration.
- def configuration(key, client = nil, clientip = nil)
- # If we want to use the cert name as our key
- if Puppet[:node_name] == 'cert' and client
- key = client
- end
-
- # Note that this is reasonable, because either their node source should actually
- # know about the node, or they should be using the ``none`` node source, which
- # will always return data.
- unless node = Puppet::Node.find_by_any_name(key)
- raise Puppet::Error, "Could not find node '%s'" % key
- end
-
- # Add any external data to the node.
- add_node_data(node)
-
- configuration = compile(node)
-
- return translate(configuration)
- end
-
- def initialize(options = {})
- options.each do |param, value|
- case param
- when :Classes: @classes = value
- when :Local: self.local = value
- else
- raise ArgumentError, "Configuration handler does not accept %s" % param
- end
- end
-
- set_server_facts
- end
-
- # Are we running locally, or are our clients networked?
- def local?
- self.local
- end
-
- # Return the configuration version.
- def version(client = nil, clientip = nil)
- if client and node = Puppet::Node.find_by_any_name(client)
- update_node_check(node)
- return interpreter.configuration_version(node)
- else
- # Just return something that will always result in a recompile, because
- # this is local.
- return (Time.now + 1000).to_i
- end
- end
-
- private
-
- # Add any extra data necessary to the node.
- def add_node_data(node)
- # Merge in our server-side facts, so they can be used during compilation.
- node.merge(@server_facts)
-
- # Add any specified classes to the node's class list.
- if @classes
- @classes.each do |klass|
- node.classes << klass
- end
- end
- end
-
- # Compile the actual configuration.
- def compile(node)
- # Pick the benchmark level.
- if local?
- level = :none
- else
- level = :notice
- end
-
- # Ask the interpreter to compile the configuration.
- str = "Compiled configuration for %s" % node.name
- if node.environment
- str += " in environment %s" % node.environment
- end
- config = nil
- benchmark(level, "Compiled configuration for %s" % node.name) do
- begin
- config = interpreter.compile(node)
- rescue => detail
- # If we're local, then we leave it to the local system
- # to handle error reporting, but otherwise we do it here
- # so the interpreter doesn't need to know if the parser
- # is local or not.
- Puppet.err(detail.to_s) unless local?
- raise
- end
- end
-
- return config
- end
-
- # Create our interpreter object.
- def create_interpreter
- return Puppet::Parser::Interpreter.new
- end
-
- # Create/return our interpreter.
- def interpreter
- unless defined?(@interpreter) and @interpreter
- @interpreter = create_interpreter
- end
- @interpreter
- end
-
- # Initialize our server fact hash; we add these to each client, and they
- # won't change while we're running, so it's safe to cache the values.
- def set_server_facts
- @server_facts = {}
-
- # Add our server version to the fact list
- @server_facts["serverversion"] = Puppet.version.to_s
-
- # And then add the server name and IP
- {"servername" => "fqdn",
- "serverip" => "ipaddress"
- }.each do |var, fact|
- if value = Facter.value(fact)
- @server_facts[var] = value
- else
- Puppet.warning "Could not retrieve fact %s" % fact
- end
- end
-
- if @server_facts["servername"].nil?
- host = Facter.value(:hostname)
- if domain = Facter.value(:domain)
- @server_facts["servername"] = [host, domain].join(".")
- else
- @server_facts["servername"] = host
- end
- end
- end
-
- # Translate our configuration appropriately for sending back to a client.
- def translate(config)
- if local?
- config
- else
- CGI.escape(config.to_yaml(:UseBlock => true))
- end
- end
-
- # Mark that the node has checked in. FIXME this needs to be moved into
- # the Node class, or somewhere that's got abstract backends.
- def update_node_check(node)
- if Puppet.features.rails? and Puppet[:storeconfigs]
- Puppet::Rails.connect
-
- host = Puppet::Rails::Host.find_or_create_by_name(node.name)
- host.last_freshcheck = Time.now
- host.save
- end
- end
- end
-end
diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb
index dabfaca50..851ccc7b2 100644
--- a/lib/puppet/network/handler/master.rb
+++ b/lib/puppet/network/handler/master.rb
@@ -23,8 +23,8 @@ class Puppet::Network::Handler
# Tell a client whether there's a fresh config for it
def freshness(client = nil, clientip = nil)
- client ||= Facter.value("hostname")
- config_handler.version(client, clientip)
+ # Always force a recompile. Newer clients shouldn't do this (as of April 2008).
+ Time.now
end
def initialize(hash = {})
@@ -51,8 +51,6 @@ class Puppet::Network::Handler
if hash.include?(:Classes)
args[:Classes] = hash[:Classes]
end
-
- @config_handler = Puppet::Network::Handler.handler(:configuration).new(args)
end
# Call our various handlers; this handler is getting deprecated.
@@ -63,13 +61,9 @@ class Puppet::Network::Handler
# Pass the facts to the fact handler
Puppet::Node::Facts.new(client, facts).save unless local?
- # And get the configuration from the config handler
- config = nil
- benchmark(:notice, "Compiled configuration for %s" % client) do
- config = config_handler.configuration(client)
- end
+ catalog = Puppet::Node::Catalog.find(client)
- return translate(config.extract)
+ return translate(catalog.extract)
end
private
@@ -93,13 +87,6 @@ class Puppet::Network::Handler
return client, clientip
end
- def config_handler
- unless defined? @config_handler
- @config_handler = Puppet::Network::Handler.handler(:config).new :local => local?
- end
- @config_handler
- end
-
#
def decode_facts(facts)
if @local
diff --git a/lib/puppet/network/xmlrpc/client.rb b/lib/puppet/network/xmlrpc/client.rb
index f6a5e8db6..357a766a1 100644
--- a/lib/puppet/network/xmlrpc/client.rb
+++ b/lib/puppet/network/xmlrpc/client.rb
@@ -49,6 +49,11 @@ module Puppet::Network
self.recycle_connection
retry
end
+ ["certificate verify failed", "hostname was not match", "hostname not match"].each do |str|
+ if detail.message.include?(str)
+ Puppet.warning "Certificate validation failed; considering using the certname configuration option"
+ end
+ end
raise XMLRPCClientError,
"Certificates were not trusted: %s" % detail
rescue ::XMLRPC::FaultException => detail