summaryrefslogtreecommitdiffstats
path: root/lib/puppet/configurer/plugin_handler.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/configurer/plugin_handler.rb')
-rw-r--r--lib/puppet/configurer/plugin_handler.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/puppet/configurer/plugin_handler.rb b/lib/puppet/configurer/plugin_handler.rb
new file mode 100644
index 000000000..cadf300fd
--- /dev/null
+++ b/lib/puppet/configurer/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::Configurer::PluginHandler
+ def download_plugins?
+ Puppet[:pluginsync]
+ end
+
+ # Retrieve facts from the central server.
+ def download_plugins
+ return nil unless download_plugins?
+ Puppet::Configurer::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