summaryrefslogtreecommitdiffstats
path: root/lib/puppet/client
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-20 00:25:35 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-20 00:25:35 +0000
commit0a1e847961977221b36d7d6c8babffe6fa69c4b6 (patch)
tree643b1f62852be92a6d03270c47135bff795e4fbf /lib/puppet/client
parentedabf9e4938b06d2c03117e4812749fb7779bce7 (diff)
Adding plugins and plugin management. The Master Client will now automatically download plugins if pluginsync is enabled, and they will be automatically sourced.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1302 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/client')
-rw-r--r--lib/puppet/client/master.rb59
1 files changed, 58 insertions, 1 deletions
diff --git a/lib/puppet/client/master.rb b/lib/puppet/client/master.rb
index 53d58daa1..cadabe33b 100644
--- a/lib/puppet/client/master.rb
+++ b/lib/puppet/client/master.rb
@@ -17,8 +17,18 @@ class Puppet::Client::MasterClient < Puppet::Client
new configurations, where you want to fix the broken configuration
rather than reverting to a known-good one."
]
+ )
-
+ Puppet.setdefaults("puppet",
+ :pluginpath => ["$vardir/plugins",
+ "Where Puppet should look for plugins. Multiple directories should
+ be comma-separated."],
+ :pluginsource => ["puppet://puppet/plugins",
+ "From where to retrieve plugins. The standard Puppet ``file`` type
+ is used for retrieval, so anything that is a valid file source can
+ be used here."],
+ :pluginsync => [true,
+ "Whether plugins should be synced with the central server."]
)
@drivername = :Master
@@ -194,6 +204,11 @@ class Puppet::Client::MasterClient < Puppet::Client
)
end
+ # Retrieve the plugins.
+ if Puppet[:pluginsync]
+ getplugins()
+ end
+
objects = nil
if @local
# If we're local, we don't have to do any of the conversion
@@ -379,6 +394,48 @@ class Puppet::Client::MasterClient < Puppet::Client
[Puppet[:classfile], detail]
end
end
+
+ private
+ # Retrieve the plugins from the central server.
+ def getplugins
+ plugins = Puppet::Type.type(:component).create(
+ :name => "plugin_collector"
+ )
+ plugins.push Puppet::Type.type(:file).create(
+ :path => Puppet[:pluginpath],
+ :recurse => true,
+ :source => Puppet[:pluginsource]
+ )
+
+ trans = plugins.evaluate
+
+ begin
+ trans.evaluate
+ rescue Puppet::Error => detail
+ if Puppet[:debug]
+ puts detail.backtrace
+ end
+ Puppet.err "Could not retrieve plugins: %s" % detail
+ end
+
+ # Now source all of the changed objects, but only source those
+ # that are top-level.
+ trans.changed?.find_all { |object|
+ File.dirname(object[:path]) == Puppet[:pluginpath]
+ }.each do |object|
+ begin
+ Puppet.info "Loading plugin %s" %
+ File.basename(object[:path]).sub(".rb",'')
+ load object[:path]
+ rescue => detail
+ Puppet.warning "Could not load %s: %s" %
+ [object[:path], detail]
+ end
+ end
+
+ # Now clean up after ourselves
+ plugins.remove
+ end
end
# $Id$