diff options
author | Luke Kanies <luke@madstop.com> | 2005-08-02 00:24:18 +0000 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2005-08-02 00:24:18 +0000 |
commit | 74dac8fd6f46c35cf79b15f1f7358bc32d4c7716 (patch) | |
tree | 8b123cbd0b481d443cb882c704e7f2e16934d702 /lib/puppet.rb | |
parent | 8bf85e2faeb8a4776b64cf6cebac4733ff3739d5 (diff) | |
download | puppet-74dac8fd6f46c35cf79b15f1f7358bc32d4c7716.tar.gz puppet-74dac8fd6f46c35cf79b15f1f7358bc32d4c7716.tar.xz puppet-74dac8fd6f46c35cf79b15f1f7358bc32d4c7716.zip |
adding some consistency and tests to the whole puppet defaults system
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@485 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet.rb')
-rw-r--r-- | lib/puppet.rb | 75 |
1 files changed, 62 insertions, 13 deletions
diff --git a/lib/puppet.rb b/lib/puppet.rb index 99ab48860..67b407ae3 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -15,6 +15,25 @@ require 'puppet/log' # # it's also a place to find top-level commands like 'debug' module Puppet +# if Process.uid == 0 +# PUPPETCONF = "/etc/puppet" +# PUPPETVAR = "/var/puppet" +# else +# PUPPETCONF = File.expand_path("~/.puppet") +# PUPPETVAR = File.expand_path("~/.puppet/var") +# end +# +# CERTDIR = File.join(PUPPETCONF, "certs") +# CERTFILE = File.join(CERTDIR, "localhost.crt") +# CERTKEY = File.join(CERTDIR, "localhost.key") +# +# RRDDIR = File.join(PUPPETROOT, "rrd") +# LOGDIR = File.join(PUPPETROOT, "log") +# LOGFILE = File.join(LOGDIR, "puppet.log") +# +# STATEDIR = File.join(PUPPETROOT, "state") +# CHECKSUMFILE = File.join(STATEDIR, "checksums") +# class Error < RuntimeError attr_accessor :stack, :line, :file def initialize(message) @@ -51,6 +70,11 @@ module Puppet # configuration parameter access and stuff def self.[](param) + if param.is_a?(String) + param = param.intern + elsif ! param.is_a?(Symbol) + raise ArgumentError, "Invalid parameter type %s" % param.class + end case param when :debug: if Puppet::Log.level == :debug @@ -63,7 +87,44 @@ module Puppet when :logdest: return Puppet::Log.destination else - return @@config[param] + if @@config.include?(param) + return @@config[param] + else + # here's where we define our defaults + returnval = case param + when :puppetconf: + if Process.uid == 0 + "/etc/puppet" + else + File.expand_path("~/.puppet/var") + end + when :puppetvar: + if Process.uid == 0 + "/var/puppet" + else + File.expand_path("~/.puppet") + end + when :rrdgraph: false + when :noop: false + when :puppetport: 8139 + when :masterport: 8140 + when :rrddir: File.join(self[:puppetvar], "rrd") + when :logdir: File.join(self[:puppetvar], "log") + when :bucketdir: File.join(self[:puppetvar], "bucket") + when :logfile: File.join(self[:logdir], "puppet.log") + when :statedir: File.join(self[:puppetvar], "state") + when :checksumfile: File.join(self[:statedir], "checksums") + when :certdir: File.join(self[:puppetconf], "certs") + when :localcert: File.join(self[:certdir], "localhost.crt") + when :localkey: File.join(self[:certdir], "localhost.key") + when :localpub: File.join(self[:certdir], "localhost.pub") + when :mastercert: File.join(self[:certdir], "puppetmaster.crt") + when :masterkey: File.join(self[:certdir], "puppetmaster.key") + when :masterpub: File.join(self[:certdir], "puppetmaster.pub") + else + raise ArgumentError, "Invalid parameter %s" % param + end + end end end @@ -100,18 +161,6 @@ module Puppet end } end - - self[:rrdgraph] = false - if Process.uid == 0 - self[:puppetroot] = "/var/puppet" - else - self[:puppetroot] = File.expand_path("~/.puppet") - end - - self[:rrddir] = File.join(self[:puppetroot],"rrd") - self[:logdir] = File.join(self[:puppetroot],"log") - self[:logfile] = File.join(self[:puppetroot],"log/puppet.log") - self[:statefile] = File.join(self[:puppetroot],"log/state") end require 'puppet/type' |