diff options
| author | Luke Kanies <luke@madstop.com> | 2005-07-18 19:51:51 +0000 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2005-07-18 19:51:51 +0000 |
| commit | b1f3fb8a9beb7a5c8407107b96d5c615f4504b7a (patch) | |
| tree | e3d8e4e3c02c8860b0ca9759211a35e35b462eba /lib | |
| parent | 357afbbc6054dcdc7a1fd5ae468a2e86a44a9bde (diff) | |
| download | puppet-b1f3fb8a9beb7a5c8407107b96d5c615f4504b7a.tar.gz puppet-b1f3fb8a9beb7a5c8407107b96d5c615f4504b7a.tar.xz puppet-b1f3fb8a9beb7a5c8407107b96d5c615f4504b7a.zip | |
switching facts to be auto-provided by the client
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@415 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet/client.rb | 23 | ||||
| -rw-r--r-- | lib/puppet/fact.rb | 1 | ||||
| -rw-r--r-- | lib/puppet/type/package.rb | 4 | ||||
| -rw-r--r-- | lib/puppet/type/pfile.rb | 48 |
4 files changed, 46 insertions, 30 deletions
diff --git a/lib/puppet/client.rb b/lib/puppet/client.rb index 0c750bfa7..a2fb6c76b 100644 --- a/lib/puppet/client.rb +++ b/lib/puppet/client.rb @@ -7,7 +7,8 @@ require 'puppet' require 'puppet/function' require 'puppet/type' -require 'puppet/fact' +#require 'puppet/fact' +require 'facter' require 'puppet/transaction' require 'puppet/transportable' require 'puppet/metric' @@ -22,6 +23,15 @@ module Puppet #--------------------------------------------------------------- class Client < SOAP::RPC::HTTPServer include Puppet + def Client.facts + facts = {} + Facter.each { |name,fact| + facts[name] = fact + } + + facts + end + def initialize(hash) # to whom do we connect? @server = nil @@ -35,7 +45,7 @@ module Puppet Puppet.debug "We're a networked client" @localonly = false @driver = SOAP::RPC::Driver.new(@url, 'urn:puppet-server') - @driver.add_method("getconfig", "name") + @driver.add_method("getconfig", "name", "facts") end unless @localonly hash.delete(:Server) @@ -56,10 +66,15 @@ module Puppet #client.loadproperty('files/sslclient.properties') Puppet.debug("getting config") objects = nil + + facts = Client.facts + Puppet.info "Facts are %s" % facts.inspect + textfacts = Marshal::dump(facts) + if @localonly - objects = @driver.getconfig(self) + objects = @driver.getconfig(self,facts) else - objects = @driver.getconfig(Puppet::Fact["hostname"]) + objects = @driver.getconfig(facts["hostname"],textfacts) end self.config(objects) end diff --git a/lib/puppet/fact.rb b/lib/puppet/fact.rb index 0a90d4e50..c9707de4f 100644 --- a/lib/puppet/fact.rb +++ b/lib/puppet/fact.rb @@ -16,6 +16,7 @@ module Puppet class Fact def Fact.[](name) fact = Facter[name] + Puppet.debug "Got fact of type %s" % fact.class if fact.value.nil? raise "Could not retrieve fact %s" % name end diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb index 49c7b4f8c..b1a544baf 100644 --- a/lib/puppet/type/package.rb +++ b/lib/puppet/type/package.rb @@ -171,8 +171,8 @@ module Puppet if @@types.include?(name) return @@types[name] else - warning name.inspect - warning @@types.keys.collect { |key| + Puppet.warning name.inspect + Puppet.warning @@types.keys.collect { |key| key.inspect }.join(" ") return nil diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb index d6c0dbdf2..44d998c1f 100644 --- a/lib/puppet/type/pfile.rb +++ b/lib/puppet/type/pfile.rb @@ -29,7 +29,7 @@ module Puppet stat = nil self.is = FileTest.exist?(self.parent[:path]) - debug "'exists' state is %s" % self.is + Puppet.debug "'exists' state is %s" % self.is end @@ -54,15 +54,15 @@ module Puppet if hash = state[self.parent[:path]] if hash.include?(@checktype) @should = hash[@checktype] - debug "Found checksum %s for %s" % + Puppet.debug "Found checksum %s for %s" % [@should,self.parent[:path]] else - debug "Found checksum for %s but not of type %s" % + Puppet.debug "Found checksum for %s but not of type %s" % [self.parent[:path],@checktype] @should = nil end else - debug "No checksum for %s" % self.parent[:path] + Puppet.debug "No checksum for %s" % self.parent[:path] end end @@ -109,7 +109,7 @@ module Puppet self.is = sum - debug "checksum state is %s" % self.is + Puppet.debug "checksum state is %s" % self.is end @@ -135,7 +135,7 @@ module Puppet result = false state = Puppet::Storage.state(self) unless state.include?(self.parent[:path]) - debug "Initializing state hash for %s" % + Puppet.debug "Initializing state hash for %s" % self.parent[:path] state[self.parent[:path]] = Hash.new @@ -145,12 +145,12 @@ module Puppet unless defined? @should raise "@should is not initialized for %s, even though we found a checksum" % self.parent[:path] end - debug "Replacing checksum %s with %s" % + Puppet.debug "Replacing checksum %s with %s" % [state[self.parent[:path]][@checktype],@is] - debug "@is: %s; @should: %s" % [@is,@should] + Puppet.debug "@is: %s; @should: %s" % [@is,@should] result = true else - debug "Creating checksum %s for %s of type %s" % + Puppet.debug "Creating checksum %s for %s of type %s" % [self.is,self.parent[:path],@checktype] result = false end @@ -168,7 +168,7 @@ module Puppet # create the link def self.create(file,link) begin - debug("Creating symlink '%s' to '%s'" % [file, link]) + Puppet.debug("Creating symlink '%s' to '%s'" % [file, link]) unless File.symlink(file,link) raise TypeError.new("Could not create symlink '%s'" % link) end @@ -181,7 +181,7 @@ module Puppet # remove an existing link def self.remove(link) if FileTest.symlink?(link) - debug("Removing symlink '%s'" % link) + Puppet.debug("Removing symlink '%s'" % link) begin File.unlink(link) rescue @@ -190,7 +190,7 @@ module Puppet elsif FileTest.exists?(link) raise TypeError.new("Cannot remove normal file '%s'" % link) else - debug("Symlink '%s' does not exist" % link) + Puppet.debug("Symlink '%s' does not exist" % link) end end @@ -247,7 +247,7 @@ module Puppet if user.gid == "" raise "Could not retrieve uid for '%s'" % self.parent end - debug "converting %s to integer '%d'" % + Puppet.debug "converting %s to integer '%d'" % [@should,user.uid] @should = user.uid rescue @@ -256,14 +256,14 @@ module Puppet end end - debug "chown state is %d" % self.is + Puppet.debug "chown state is %d" % self.is end def sync if @is == -1 self.parent.stat(true) self.retrieve - debug "%s: after refresh, is '%s'" % [self.class.name,@is] + Puppet.debug "%s: after refresh, is '%s'" % [self.class.name,@is] end unless self.parent.stat @@ -307,14 +307,14 @@ module Puppet stat = self.parent.stat(true) self.is = stat.mode & 007777 - debug "chmod state is %o" % self.is + Puppet.debug "chmod state is %o" % self.is end def sync if @is == -1 self.parent.stat(true) self.retrieve - debug "%s: after refresh, is '%s'" % [self.class.name,@is] + Puppet.debug "%s: after refresh, is '%s'" % [self.class.name,@is] end unless self.parent.stat @@ -351,7 +351,7 @@ module Puppet unless defined? @is or @is == -1 self.parent.stat(true) self.retrieve - debug "%s: should is '%s'" % [self.class.name,self.should] + Puppet.debug "%s: should is '%s'" % [self.class.name,self.should] end tmp = 0 if self.is == true @@ -394,7 +394,7 @@ module Puppet if gid == "" raise "Could not retrieve gid for %s" % self.parent end - debug "converting %s to integer %d" % + Puppet.debug "converting %s to integer %d" % [self.should,gid] self.should = gid rescue @@ -403,15 +403,15 @@ module Puppet end end end - debug "chgrp state is %d" % self.is + Puppet.debug "chgrp state is %d" % self.is end def sync - debug "setting chgrp state to %s" % self.should + Puppet.debug "setting chgrp state to %s" % self.should if @is == -1 self.parent.stat(true) self.retrieve - debug "%s: after refresh, is '%s'" % [self.class.name,@is] + Puppet.debug "%s: after refresh, is '%s'" % [self.class.name,@is] end unless self.parent.stat @@ -456,7 +456,7 @@ module Puppet # a wrapper method to make sure the file exists before doing anything def retrieve unless stat = self.stat(true) - debug "PFile %s does not exist" % self[:path] + Puppet.debug "PFile %s does not exist" % self[:path] @states.each { |name,state| state.is = -1 } @@ -470,7 +470,7 @@ module Puppet begin @stat = File.stat(self[:path]) rescue => error - debug "Failed to stat %s: %s" % + Puppet.debug "Failed to stat %s: %s" % [self[:path],error] @stat = nil end |
