diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-02-07 23:12:33 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-02-07 23:12:33 +0000 |
commit | b98e65f1fd858a1d0af415554db49a121a76232c (patch) | |
tree | 728f94dd17f88902c6bdf21ff6b17486babb08af /lib/puppet.rb | |
parent | f1ffc34c0927840beeb21e1e2d864ce14de5d15e (diff) | |
download | puppet-b98e65f1fd858a1d0af415554db49a121a76232c.tar.gz puppet-b98e65f1fd858a1d0af415554db49a121a76232c.tar.xz puppet-b98e65f1fd858a1d0af415554db49a121a76232c.zip |
There is now full support for configuration files, and the entire system has been modified to expect their new behaviour. I have not yet run the test across all test hosts, though.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@873 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet.rb')
-rw-r--r-- | lib/puppet.rb | 109 |
1 files changed, 82 insertions, 27 deletions
diff --git a/lib/puppet.rb b/lib/puppet.rb index fa3aafb87..f31f1d749 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -102,28 +102,42 @@ module Puppet var = "/var/puppet" end self.setdefaults("puppet", - [:puppetconf, conf, "The main Puppet configuration directory."], - [:puppetvar, var, "Where Puppet stores dynamic and growing data."] + [:confdir, conf, "The main Puppet configuration directory."], + [:vardir, var, "Where Puppet stores dynamic and growing data."] + ) + + # Define the config default. + self.setdefaults(self.name, + [:config, "$confdir/#{self.name}.conf", + "The configuration file for #{self.name}."] ) self.setdefaults("puppet", - [:logdir, "$puppetvar/log", + [:logdir, "$vardir/log", "The Puppet log directory."], - [:bucketdir, "$puppetvar/bucket", + [:bucketdir, "$vardir/bucket", "Where FileBucket files are stored."], - [:statedir, "$puppetvar/state", + [:statedir, "$vardir/state", "The directory where Puppet state is stored. Generally, this directory can be removed without causing harm (although it might result in spurious service restarts)."], - [:rundir, "$puppetvar/run", "Where Puppet PID files are kept."], + [:rundir, "$vardir/run", "Where Puppet PID files are kept."], [:statefile, "$statedir/state.yaml", "Where puppetd and puppetmasterd store state associated with the running configuration. In the case of puppetmasterd, this file reflects the state discovered through interacting with clients."], - [:ssldir, "$puppetconf/ssl", "Where SSL certificates are kept."] + [:ssldir, "$confdir/ssl", "Where SSL certificates are kept."], + [:genconfig, false, + "Whether to just print a configuration to stdout and exit. Only makes + sense when used interactively. Takes into account arguments specified + on the CLI."], + [:genmanifest, false, + "Whether to just print a manifest to stdout and exit. Only makes + sense when used interactively. Takes into account arguments specified + on the CLI."] ) self.setdefaults("puppetmasterd", - [:manifestdir, "$puppetconf/manifests", + [:manifestdir, "$confdir/manifests", "Where puppetmasterd looks for its manifests."], [:manifest, "$manifestdir/site.pp", "The entry-point manifest for puppetmasterd."], @@ -137,15 +151,15 @@ module Puppet ) self.setdefaults("puppetd", - [:localconfig, "$puppetconf/localconfig", + [:localconfig, "$confdir/localconfig", "Where puppetd caches the local configuration. An extension reflecting the cache format is added automatically."], - [:classfile, "$puppetconf/classes.txt", + [:classfile, "$confdir/classes.txt", "The file in which puppetd stores a list of the classes associated with the retrieved configuratiion."], [:puppetdlog, "$logdir/puppetd.log", "The log file for puppetd. This is generally not used."], - [:httplogfile, "$logdir/http.log", "Where the puppetd web server logs."], + [:httplog, "$logdir/http.log", "Where the puppetd web server logs."], [:server, "puppet", "The server to which server puppetd should connect"], [:user, "puppet", "The user puppetmasterd should run as."], @@ -159,41 +173,74 @@ module Puppet "How often puppetd applies the client configuration; in seconds"] ) self.setdefaults("metrics", - [:rrddir, "$puppetvar/rrd", + [:rrddir, "$vardir/rrd", "The directory where RRD database files are stored."], [:rrdgraph, false, "Whether RRD information should be graphed."] ) # configuration parameter access and stuff def self.[](param) - @@config[param] - end - - # configuration parameter access and stuff - def self.[]=(param,value) case param when :debug: - if value - Puppet::Log.level=(:debug) + if Puppet::Log.level == :debug + return true else - Puppet::Log.level=(:notice) + return false end - when :loglevel: - Puppet::Log.level=(value) - when :logdest: - Puppet::Log.newdestination(value) else - @@config[param] = value + return @@config[param] end end + # configuration parameter access and stuff + def self.[]=(param,value) + @@config[param] = value +# case param +# when :debug: +# if value +# Puppet::Log.level=(:debug) +# else +# Puppet::Log.level=(:notice) +# end +# when :loglevel: +# Puppet::Log.level=(value) +# when :logdest: +# Puppet::Log.newdestination(value) +# else +# @@config[param] = value +# end + end + def self.clear @@config.clear end + def self.debug=(value) + if value + Puppet::Log.level=(:debug) + else + Puppet::Log.level=(:notice) + end + end + def self.config @@config end + + def self.genconfig + if Puppet[:genconfig] + puts Puppet.config.to_config + exit(0) + end + end + + def self.genmanifest + if Puppet[:genmanifest] + puts Puppet.config.to_manifest + exit(0) + end + end + # Start our event loop. This blocks, waiting for someone, somewhere, # to generate events of some kind. def self.start @@ -258,11 +305,19 @@ module Puppet tmp.split(File::SEPARATOR).each { |dir| path.push dir if ! FileTest.exist?(File.join(path)) - Dir.mkdir(File.join(path), mode) + begin + Dir.mkdir(File.join(path), mode) + rescue Errno::EACCES => detail + Puppet.err detail.to_s + return false + rescue => detail + Puppet.err "Could not create %s: %s" % [path, detail.to_s] + return false + end elsif FileTest.directory?(File.join(path)) next else FileTest.exist?(File.join(path)) - raise "Cannot create %s: basedir %s is a file" % + raise Puppet::Error, "Cannot create %s: basedir %s is a file" % [dir, File.join(path)] end } |