summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-03-01 23:09:23 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-03-01 23:09:23 +0000
commit2db23173825311bc4a9d6f69e862ce0a9c43fd40 (patch)
treef081893e98ffef11943e82c8fd7cffc2b40a2fc8 /lib
parent179779dc5045259aa28f0a9cd052d2e41cf8aa96 (diff)
downloadpuppet-2db23173825311bc4a9d6f69e862ce0a9c43fd40.tar.gz
puppet-2db23173825311bc4a9d6f69e862ce0a9c43fd40.tar.xz
puppet-2db23173825311bc4a9d6f69e862ce0a9c43fd40.zip
Adding metadata to defaults
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@963 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet.rb102
-rw-r--r--lib/puppet/config.rb44
-rwxr-xr-xlib/puppet/server/filebucket.rb9
3 files changed, 103 insertions, 52 deletions
diff --git a/lib/puppet.rb b/lib/puppet.rb
index 84df0fad5..deb5abce3 100644
--- a/lib/puppet.rb
+++ b/lib/puppet.rb
@@ -84,9 +84,8 @@ module Puppet
alias :error :err
# Store a new default value.
- def self.setdefaults(section, *arrays)
- start = Time.now
- @@config.setdefaults(section, *arrays)
+ def self.setdefaults(section, hash)
+ @@config.setdefaults(section, hash)
end
# If we're running the standalone puppet process as a non-root user,
@@ -113,21 +112,36 @@ module Puppet
)
self.setdefaults("puppet",
- :logdir => ["$vardir/log",
- "The Puppet log directory."],
- :bucketdir => ["$vardir/bucket",
- "Where FileBucket files are stored."],
- :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",
- "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."],
+ :logdir => ["$vardir/log", "The Puppet log directory."],
+ :statedir => { :default => "$vardir/state",
+ :mode => 01777,
+ :desc => "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 => { :default => "$vardir/run",
+ :mode => 01777,
+ :desc => "Where Puppet PID files are kept."
+ },
+ :lockdir => { :default => "$vardir/locks",
+ :mode => 01777,
+ :desc => "Where lock files are kept."
+ },
+ :statefile => { :default => "$statedir/state.yaml",
+ :mode => 0770,
+ :owner => "$user",
+ :owner => "$group",
+ :desc => "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 => {
+ :default => "$confdir/ssl",
+ :mode => 0770,
+ :owner => "root",
+ :desc => "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
@@ -138,33 +152,53 @@ module Puppet
on the CLI."]
)
self.setdefaults("puppetmasterd",
+ :user => ["puppet", "The user puppetmasterd should run as."],
+ :group => ["puppet", "The group puppetmasterd should run as."],
:manifestdir => ["$confdir/manifests",
"Where puppetmasterd looks for its manifests."],
:manifest => ["$manifestdir/site.pp",
"The entry-point manifest for puppetmasterd."],
- :masterlog => ["$logdir/puppetmaster.log",
- "Where puppetmasterd logs. This is generally not used, since syslog
- is the default log destination."],
- :masterhttplog => ["$logdir/masterhttp.log",
- "Where the puppetmasterd web server logs."],
+ :masterlog => { :default => "$logdir/puppetmaster.log",
+ :owner => "$user",
+ :group => "$group",
+ :mode => 0660,
+ :desc => "Where puppetmasterd logs. This is generally not used,
+ since syslog is the default log destination."
+ },
+ :masterhttplog => { :default => "$logdir/masterhttp.log",
+ :owner => "$user",
+ :group => "$group",
+ :mode => 0660,
+ :create => true,
+ :desc => "Where the puppetmasterd web server logs."
+ },
: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
- 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",
- "The log file for puppetd. This is generally not used."],
- :httplog => ["$logdir/http.log", "Where the puppetd web server logs."],
+ :localconfig => { :default => "$confdir/localconfig",
+ :owner => "root",
+ :mode => 0660,
+ :desc => "Where puppetd caches the local configuration. An
+ extension indicating the cache format is added automatically."},
+ :classfile => { :default => "$confdir/classes.txt",
+ :owner => "root",
+ :mode => 0644,
+ :desc => "The file in which puppetd stores a list of the classes
+ associated with the retrieved configuratiion."},
+ :puppetdlog => { :default => "$logdir/puppetd.log",
+ :owner => "root",
+ :mode => 0640,
+ :desc => "The log file for puppetd. This is generally not used."
+ },
+ :httplog => { :default => "$logdir/http.log",
+ :owner => "root",
+ :mode => 0640,
+ :desc => "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,
"Boolean; whether puppetd should ignore schedules. This is useful
for initial puppetd runs."],
diff --git a/lib/puppet/config.rb b/lib/puppet/config.rb
index dd08552a5..b165192e5 100644
--- a/lib/puppet/config.rb
+++ b/lib/puppet/config.rb
@@ -1,3 +1,6 @@
+require 'puppet'
+require 'puppet/transportable'
+
module Puppet
# The class for handling configuration files.
class Config
@@ -460,6 +463,22 @@ Generated on #{Time.now}.
@value = nil
end
+ def convert(value)
+ return value unless value
+ return value unless value.is_a? String
+ if value =~ /\$(\w+)/
+ parent = $1
+ if pval = @parent[parent]
+ newval = value.sub(/\$#{parent}/, pval)
+ return File.join(newval.split("/"))
+ else
+ raise Puppet::DevError, "Could not find value for %s" % parent
+ end
+ else
+ return value
+ end
+ end
+
def desc=(value)
@desc = value.gsub(/^\s*/, '')
end
@@ -554,23 +573,7 @@ Generated on #{Time.now}.
# A file.
class CFile < CElement
- attr_accessor :owner, :group, :mode
-
- def convert(value)
- return value unless value
- return value unless value.is_a? String
- if value =~ /\$(\w+)/
- parent = $1
- if pval = @parent[parent]
- newval = value.sub(/\$#{parent}/, pval)
- return File.join(newval.split("/"))
- else
- raise Puppet::DevError, "Could not find value for %s" % parent
- end
- else
- return value
- end
- end
+ attr_accessor :owner, :group, :mode, :create
# Set the type appropriately. Yep, a hack. This supports either naming
# the variable 'dir', or adding a slash at the end.
@@ -608,7 +611,12 @@ Generated on #{Time.now}.
objects = []
obj = Puppet::TransObject.new(self.value, "file")
- obj[:ensure] = type
+
+ # Only create directories, or files that are specifically marked to
+ # create.
+ if type == :directory or self.create
+ obj[:ensure] = type
+ end
[:owner, :group, :mode].each { |var|
if value = self.send(var)
obj[var] = value
diff --git a/lib/puppet/server/filebucket.rb b/lib/puppet/server/filebucket.rb
index b211379f1..fc1c690fd 100755
--- a/lib/puppet/server/filebucket.rb
+++ b/lib/puppet/server/filebucket.rb
@@ -15,6 +15,15 @@ module Puppet
class Server
class BucketError < RuntimeError; end
class FileBucket < Handler
+ Puppet.config.setdefaults("filebucket",
+ :bucketdir => {
+ :default => "$vardir/bucket",
+ :mode => 0770,
+ :owner => "$user",
+ :group => "$group",
+ :desc => "Where FileBucket files are stored."
+ }
+ )
@interface = XMLRPC::Service::Interface.new("puppetbucket") { |iface|
iface.add_method("string addfile(string, string)")
iface.add_method("string getfile(string)")