summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-03-01 22:28:27 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-03-01 22:28:27 +0000
commit179779dc5045259aa28f0a9cd052d2e41cf8aa96 (patch)
treeab27ba4a6235bf5b53c90a5bff6de274811cc551 /lib
parent457492836e092374895122e69fa067299bf112ff (diff)
downloadpuppet-179779dc5045259aa28f0a9cd052d2e41cf8aa96.tar.gz
puppet-179779dc5045259aa28f0a9cd052d2e41cf8aa96.tar.xz
puppet-179779dc5045259aa28f0a9cd052d2e41cf8aa96.zip
Changing the setdefaults input format somewhat. It is always a hash of some kind now.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@962 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet.rb110
-rw-r--r--lib/puppet/client/master.rb2
-rw-r--r--lib/puppet/config.rb12
-rw-r--r--lib/puppet/parser/ast.rb4
-rw-r--r--lib/puppet/parser/interpreter.rb18
-rwxr-xr-xlib/puppet/server/fileserver.rb2
-rw-r--r--lib/puppet/sslcertificates/ca.rb38
7 files changed, 71 insertions, 115 deletions
diff --git a/lib/puppet.rb b/lib/puppet.rb
index 012db02d9..84df0fad5 100644
--- a/lib/puppet.rb
+++ b/lib/puppet.rb
@@ -102,81 +102,81 @@ module Puppet
var = "/var/puppet"
end
self.setdefaults("puppet",
- [:confdir, conf, "The main Puppet configuration directory."],
- [:vardir, 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",
+ :config => ["$confdir/#{self.name}.conf",
"The configuration file for #{self.name}."]
)
self.setdefaults("puppet",
- [:logdir, "$vardir/log",
+ :logdir => ["$vardir/log",
"The Puppet log directory."],
- [:bucketdir, "$vardir/bucket",
+ :bucketdir => ["$vardir/bucket",
"Where FileBucket files are stored."],
- [:statedir, "$vardir/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, "$vardir/run", "Where Puppet PID files are kept."],
- [:lockdir, "$vardir/locks", "Where lock files are kept."],
- [:statefile, "$statedir/state.yaml",
+ :rundir => ["$vardir/run", "Where Puppet PID files are kept."],
+ :lockdir => ["$vardir/locks", "Where lock 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, "$confdir/ssl", "Where SSL certificates are kept."],
- [:genconfig, false,
+ :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,
+ :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, "$confdir/manifests",
+ :manifestdir => ["$confdir/manifests",
"Where puppetmasterd looks for its manifests."],
- [:manifest, "$manifestdir/site.pp",
+ :manifest => ["$manifestdir/site.pp",
"The entry-point manifest for puppetmasterd."],
- [:masterlog, "$logdir/puppetmaster.log",
+ :masterlog => ["$logdir/puppetmaster.log",
"Where puppetmasterd logs. This is generally not used, since syslog
is the default log destination."],
- [:masterhttplog, "$logdir/masterhttp.log",
+ :masterhttplog => ["$logdir/masterhttp.log",
"Where the puppetmasterd web server logs."],
- [:masterport, 8140, "Which port puppetmasterd listens on."],
- [:parseonly, false, "Just check the syntax of the manifests."]
+ :masterport => [8140, "Which port puppetmasterd listens on."],
+ :parseonly => [false, "Just check the syntax of the manifests."]
)
self.setdefaults("puppetd",
- [:localconfig, "$confdir/localconfig",
- "Where puppetd caches the local configuration. An extension reflecting
- the cache format is added automatically."],
- [:classfile, "$confdir/classes.txt",
+ :localconfig => ["$confdir/localconfig",
+ "Where puppetd caches the local configuration. An extension
+ indicating the cache format is added automatically."],
+ :classfile => ["$confdir/classes.txt",
"The file in which puppetd stores a list of the classes associated
with the retrieved configuratiion."],
- [:puppetdlog, "$logdir/puppetd.log",
+ :puppetdlog => ["$logdir/puppetd.log",
"The log file for puppetd. This is generally not used."],
- [:httplog, "$logdir/http.log", "Where the puppetd web server logs."],
- [:server, "puppet",
+ :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."],
- [:group, "puppet", "The group puppetmasterd should run as."],
- [:ignoreschedules, false,
+ :user => ["puppet", "The user puppetmasterd should run as."],
+ :group => ["puppet", "The group puppetmasterd should run as."],
+ :ignoreschedules => [false,
"Boolean; whether puppetd should ignore schedules. This is useful
for initial puppetd runs."],
- [:puppetport, 8139, "Which port puppetd listens on."],
- [:noop, false, "Whether puppetd should be run in noop mode."],
- [:runinterval, 1800, # 30 minutes
+ :puppetport => [8139, "Which port puppetd listens on."],
+ :noop => [false, "Whether puppetd should be run in noop mode."],
+ :runinterval => [1800, # 30 minutes
"How often puppetd applies the client configuration; in seconds"]
)
self.setdefaults("metrics",
- [:rrddir, "$vardir/rrd",
+ :rrddir => ["$vardir/rrd",
"The directory where RRD database files are stored."],
- [:rrdgraph, false, "Whether RRD information should be graphed."]
+ :rrdgraph => [false, "Whether RRD information should be graphed."]
)
# configuration parameter access and stuff
@@ -196,20 +196,6 @@ module Puppet
# 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
@@ -265,36 +251,6 @@ module Puppet
@timer
end
- # Store a new default value.
-# def self.setdefaults(section, hash)
-# @@config.setdefaults(section, hash)
-# if value.is_a?(Array)
-# if value[0].is_a?(Symbol)
-# unless @defaults.include?(value[0])
-# raise ArgumentError, "Unknown basedir %s for param %s" %
-# [value[0], param]
-# end
-# else
-# raise ArgumentError, "Invalid default %s for param %s" %
-# [value.inspect, param]
-# end
-#
-# unless value[1].is_a?(String)
-# raise ArgumentError, "Invalid default %s for param %s" %
-# [value.inspect, param]
-# end
-#
-# unless value.length == 2
-# raise ArgumentError, "Invalid default %s for param %s" %
-# [value.inspect, param]
-# end
-#
-# @defaults[param] = value
-# else
-# @defaults[param] = value
-# end
-# end
-
# XXX this should all be done using puppet objects, not using
# normal mkdir
def self.recmkdir(dir,mode = 0755)
diff --git a/lib/puppet/client/master.rb b/lib/puppet/client/master.rb
index be7f3748d..f9694fb3d 100644
--- a/lib/puppet/client/master.rb
+++ b/lib/puppet/client/master.rb
@@ -1,7 +1,7 @@
# The client for interacting with the puppetmaster config server.
class Puppet::Client::MasterClient < Puppet::Client
Puppet.setdefaults("puppetd",
- [:puppetdlockfile, "$statedir/puppetdlock",
+ :puppetdlockfile => [ "$statedir/puppetdlock",
"A lock file to temporarily stop puppetd from doing anything."]
)
diff --git a/lib/puppet/config.rb b/lib/puppet/config.rb
index aa9f6f9c7..dd08552a5 100644
--- a/lib/puppet/config.rb
+++ b/lib/puppet/config.rb
@@ -253,7 +253,7 @@ class Config
when String, Integer, Float: # nothing
klass = CElement
else
- raise Puppet::Error, "Invalid value '%s' for %s" % [value, param]
+ raise Puppet::Error, "Invalid value '%s' for %s" % [value, hash[:name]]
end
element = klass.new(hash)
element.parent = self
@@ -345,16 +345,16 @@ class Config
# Set a bunch of defaults in a given section. The sections are actually pretty
# pointless, but they help break things up a bit, anyway.
- def setdefaults(section, *defs)
+ def setdefaults(section, defs)
section = symbolize(section)
- #hash.each { |param, value|
- defs.each { |hash|
+ defs.each { |name, hash|
if hash.is_a? Array
tmp = hash
hash = {}
- [:name, :default, :desc].zip(tmp).each { |p, v| hash[p] = v }
+ [:default, :desc].zip(tmp).each { |p,v| hash[p] = v }
end
- hash[:name] = symbolize(hash[:name])
+ name = symbolize(name)
+ hash[:name] = name
hash[:section] = section
name = hash[:name]
if @config.include?(name)
diff --git a/lib/puppet/parser/ast.rb b/lib/puppet/parser/ast.rb
index 7aedfb1cc..03f390fa9 100644
--- a/lib/puppet/parser/ast.rb
+++ b/lib/puppet/parser/ast.rb
@@ -12,8 +12,8 @@ module Puppet
AST = Puppet::Parser::AST
Puppet.setdefaults("ast",
- [:typecheck, true, "Whether to validate types during parsing."],
- [:paramcheck, true, "Whether to validate parameters during parsing."]
+ :typecheck => [true, "Whether to validate types during parsing."],
+ :paramcheck => [true, "Whether to validate parameters during parsing."]
)
attr_accessor :line, :file, :parent, :scope
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb
index 5e4844498..73234fbf9 100644
--- a/lib/puppet/parser/interpreter.rb
+++ b/lib/puppet/parser/interpreter.rb
@@ -11,25 +11,25 @@ module Puppet
module Parser
class Interpreter
Puppet.setdefaults("ldap",
- [:ldapnodes, false,
+ :ldapnodes => [false,
"Whether to search for node configurations in LDAP."],
- [:ldapserver, "ldap",
+ :ldapserver => ["ldap",
"The LDAP server. Only used if ``ldapnodes`` is enabled."],
- [:ldapport, 389,
+ :ldapport => [389,
"The LDAP port. Only used if ``ldapnodes`` is enabled."],
- [:ldapstring, "(&(objectclass=puppetClient)(cn=%s))",
+ :ldapstring => ["(&(objectclass=puppetClient)(cn=%s))",
"The search string used to find an LDAP node."],
- [:ldapattrs, "puppetclass",
+ :ldapattrs => ["puppetclass",
"The LDAP attributes to use to define Puppet classes. Values
should be comma-separated."],
- [:ldapparentattr, "parentnode",
+ :ldapparentattr => ["parentnode",
"The attribute to use to define the parent node."],
- [:ldapuser, "",
+ :ldapuser => ["",
"The user to use to connect to LDAP. Must be specified as a
full DN."],
- [:ldappassword, "",
+ :ldappassword => ["",
"The password to use to connect to LDAP."],
- [:ldapbase, "",
+ :ldapbase => ["",
"The search base for LDAP searches. It's impossible to provide
a meaningful default here, although the LDAP libraries might
have one already set. Generally, it should be the 'ou=Hosts'
diff --git a/lib/puppet/server/fileserver.rb b/lib/puppet/server/fileserver.rb
index 067f1da0f..eb49a7d3e 100755
--- a/lib/puppet/server/fileserver.rb
+++ b/lib/puppet/server/fileserver.rb
@@ -9,7 +9,7 @@ class Server
attr_accessor :local
Puppet.setdefaults("fileserver",
- [:fileserverconfig, "$confdir/fileserver.conf",
+ :fileserverconfig => ["$confdir/fileserver.conf",
"Where the fileserver configuration is stored."])
#CHECKPARAMS = %w{checksum type mode owner group}
diff --git a/lib/puppet/sslcertificates/ca.rb b/lib/puppet/sslcertificates/ca.rb
index 901b098bf..9fec908d6 100644
--- a/lib/puppet/sslcertificates/ca.rb
+++ b/lib/puppet/sslcertificates/ca.rb
@@ -3,38 +3,38 @@ class Puppet::SSLCertificates::CA
attr_accessor :keyfile, :file, :config, :dir, :cert
Puppet.setdefaults("ca",
- [:certdir, "$ssldir/certs", "The certificate directory."],
- [:publickeydir, "$ssldir/public_keys", "The public key directory."],
- [:privatekeydir, "$ssldir/private_keys", "The private key directory."],
- [:cadir, "$ssldir/ca",
+ :certdir => ["$ssldir/certs", "The certificate directory."],
+ :publickeydir => ["$ssldir/public_keys", "The public key directory."],
+ :privatekeydir => ["$ssldir/private_keys", "The private key directory."],
+ :cadir => ["$ssldir/ca",
"The root directory for the certificate authority."],
- [:cacert, "$cadir/ca_crt.pem", "The CA certificate."],
- [:cakey, "$cadir/ca_key.pem", "The CA private key."],
- [:capub, "$cadir/ca_pub.pem", "The CA public key."],
- [:caprivatedir, "$cadir/private",
+ :cacert => ["$cadir/ca_crt.pem", "The CA certificate."],
+ :cakey => ["$cadir/ca_key.pem", "The CA private key."],
+ :capub => ["$cadir/ca_pub.pem", "The CA public key."],
+ :caprivatedir => ["$cadir/private",
"Where the CA stores private certificate information."],
- [:csrdir, "$cadir/requests",
+ :csrdir => ["$cadir/requests",
"Where the CA stores certificate requests"],
- [:signeddir, "$cadir/signed",
+ :signeddir => ["$cadir/signed",
"Where the CA stores signed certificates."],
- [:capass, "$caprivatedir/ca.pass",
+ :capass => ["$caprivatedir/ca.pass",
"Where the CA stores the password for the private key"],
- [:serial, "$cadir/serial",
+ :serial => ["$cadir/serial",
"Where the serial number for certificates is stored."],
- [:privatedir, "$ssldir/private",
+ :privatedir => ["$ssldir/private",
"Where the client stores private certificate information."],
- [:passfile, "$privatedir/password",
+ :passfile => ["$privatedir/password",
"Where puppetd stores the password for its private key. Generally
unused."],
- [:autosign, "$confdir/autosign.conf",
+ :autosign => ["$confdir/autosign.conf",
"Whether to enable autosign. Valid values are true (which autosigns
any key request, and is a very bad idea), false (which never autosigns
any key request), and the path to a file, which uses that configuration
file to determine which keys to sign."],
- [:ca_days, 1825, "How long a certificate should be valid."],
- [:ca_md, "md5", "The type of hash used in certificates."],
- [:req_bits, 2048, "The bit length of the certificates."],
- [:keylength, 1024, "The bit length of keys."]
+ :ca_days => [1825, "How long a certificate should be valid."],
+ :ca_md => ["md5", "The type of hash used in certificates."],
+ :req_bits => [2048, "The bit length of the certificates."],
+ :keylength => [1024, "The bit length of keys."]
)
#@@params.each { |param|