From d24c1ccc56b912e0ff69f7572dd36912c8c739c2 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Mon, 8 Oct 2007 19:12:39 -0500 Subject: All tests should now pass again. This is the first real pass towards using caching. The `puppet` executable actually uses the indirection work, instead of handlers and such (and man! is it cleaner). Most of this work was a result of trying to get the client-side story working, with correct yaml caching of configurations, which means this commit also covers converting configurations to yaml, which was a much bigger PITA than it needed to be. I still need to write integration tests, and I also need to cover the server-side story of a normal configuration retrieval. --- ext/module_puppet | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) (limited to 'ext') diff --git a/ext/module_puppet b/ext/module_puppet index 52f65b094..36efb4f0e 100755 --- a/ext/module_puppet +++ b/ext/module_puppet @@ -150,14 +150,23 @@ unless setdest Puppet::Util::Log.newdestination(:syslog) end -master[:Manifest] = ARGV.shift +Puppet[:manifest] = ARGV.shift unless ENV.include?("CFALLCLASSES") $stderr.puts "Cfengine classes must be passed to the module" exit(15) end -master[:UseNodes] = false +# Collect our facts. +Puppet::Node::Facts.terminus_class = :code +facts = Puppet::Node::Facts.find("me") +facts.name = facts.values["hostname"] + +# Create our Node +node = Puppet::Node.new(facts.name) + +# Merge in the facts. +node.merge(facts.values) classes = ENV["CFALLCLASSES"].split(":") @@ -166,32 +175,32 @@ if classes.empty? exit(16) end -master[:Classes] = classes +node.classes = classes begin - server = Puppet::Network::Handler.master.new(master) + # Compile our configuration + config = Puppet::Node::Configuration.find(node) rescue => detail - $stderr.puts detail - exit(1) -end - -begin - client = Puppet::Network::Client.master.new( - :Master => server, - :Cache => false - ) -rescue => detail - $stderr.puts detail + if Puppet[:trace] + puts detail.backtrace + end + if detail.is_a?(XMLRPC::FaultException) + $stderr.puts detail.message + else + $stderr.puts detail + end exit(1) end - if parseonly exit(0) end begin - config = client.getconfig + # Translate it to a RAL configuration + config = config.to_ral + + # And apply it config.apply rescue => detail Puppet.err detail -- cgit