summaryrefslogtreecommitdiffstats
path: root/lib/puppet/agent/plugin_handler.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-01-22 16:05:43 -0600
committerLuke Kanies <luke@madstop.com>2009-02-06 18:08:40 -0600
commit54faf7825bbffc5a4ca252389305dd23ae8d2d84 (patch)
treec9d059cb83b3f0de52ddc52c33278eb53dd2edd7 /lib/puppet/agent/plugin_handler.rb
parent9d76b70c07c86f0041a0e6a1537227de1b619017 (diff)
downloadpuppet-54faf7825bbffc5a4ca252389305dd23ae8d2d84.tar.gz
puppet-54faf7825bbffc5a4ca252389305dd23ae8d2d84.tar.xz
puppet-54faf7825bbffc5a4ca252389305dd23ae8d2d84.zip
Moving fact and plugin handling into modules
This doesn't change functionality, it just simplifies the agent class. I've also started the work to get the catalog handling done using REST/the Indirector. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet/agent/plugin_handler.rb')
-rw-r--r--lib/puppet/agent/plugin_handler.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/puppet/agent/plugin_handler.rb b/lib/puppet/agent/plugin_handler.rb
new file mode 100644
index 000000000..306b8b6df
--- /dev/null
+++ b/lib/puppet/agent/plugin_handler.rb
@@ -0,0 +1,25 @@
+# Break out the code related to plugins. This module is
+# just included into the agent, but having it here makes it
+# easier to test.
+module Puppet::Agent::PluginHandler
+ def download_plugins?
+ Puppet[:pluginsync]
+ end
+
+ # Retrieve facts from the central server.
+ def download_plugins
+ return nil unless download_plugins?
+ Puppet::Agent::Downloader.new("plugin", Puppet[:pluginsource], Puppet[:plugindest], Puppet[:pluginsignore]).evaluate.each { |file| load_plugin(file) }
+ end
+
+ def load_plugin(file)
+ return if FileTest.directory?(file)
+
+ begin
+ Puppet.info "Loading downloaded plugin %s" % file
+ load file
+ rescue Exception => detail
+ Puppet.err "Could not load downloaded file %s: %s" % [file, detail]
+ end
+ end
+end