diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb index c238da5d4..b0deac5bc 100644 --- a/lib/puppet/parser/functions.rb +++ b/lib/puppet/parser/functions.rb @@ -1,122 +1,122 @@ require 'puppet/util/autoload' require 'puppet/parser/scope' require 'monitor' # A module for managing parser functions. Each specified function # is added to a central module that then gets included into the Scope # class. module Puppet::Parser::Functions (@functions = Hash.new { |h,k| h[k] = {} }).extend(MonitorMixin) (@modules = {} ).extend(MonitorMixin) class << self include Puppet::Util end def self.autoloader unless defined?(@autoloader) @autoloader = Puppet::Util::Autoload.new( self, "puppet/parser/functions", - + :wrap => false ) end @autoloader end Environment = Puppet::Node::Environment def self.environment_module(env = nil) @modules.synchronize { @modules[ env || Environment.current || Environment.root ] ||= Module.new } end # Create a new function type. def self.newfunction(name, options = {}, &block) name = symbolize(name) raise Puppet::DevError, "Function #{name} already defined" if functions.include?(name) ftype = options[:type] || :statement unless ftype == :statement or ftype == :rvalue raise Puppet::DevError, "Invalid statement type #{ftype.inspect}" end fname = "function_#{name}" environment_module.send(:define_method, fname, &block) # Someday we'll support specifying an arity, but for now, nope #functions[name] = {:arity => arity, :type => ftype} functions[name] = {:type => ftype, :name => fname} functions[name][:doc] = options[:doc] if options[:doc] end # Remove a function added by newfunction def self.rmfunction(name) name = symbolize(name) raise Puppet::DevError, "Function #{name} is not defined" unless functions.include? name functions.delete name fname = "function_#{name}" environment_module.send(:remove_method, fname) end # Determine if a given name is a function def self.function(name) name = symbolize(name) unless functions.include?(name) or functions(Puppet::Node::Environment.root).include?(name) autoloader.load(name,Environment.current || Environment.root) end ( functions(Environment.root)[name] || functions[name] || {:name => false} )[:name] end def self.functiondocs autoloader.loadall ret = "" functions.sort { |a,b| a[0].to_s <=> b[0].to_s }.each do |name, hash| #ret += "#{name}\n#{hash[:type]}\n" ret += "#{name}\n#{"-" * name.to_s.length}\n" if hash[:doc] ret += Puppet::Util::Docs.scrub(hash[:doc]) else ret += "Undocumented.\n" end - ret += "\n\n- **Type**: #{hash[:type]}\n\n" + ret += "\n\n- *Type*: #{hash[:type]}\n\n" end ret end def self.functions(env = nil) @functions.synchronize { @functions[ env || Environment.current || Environment.root ] } end # Determine if a given function returns a value or not. def self.rvalue?(name) (functions[symbolize(name)] || {})[:type] == :rvalue end # Runs a newfunction to create a function for each of the log levels Puppet::Util::Log.levels.each do |level| newfunction(level, :doc => "Log a message on the server at level #{level.to_s}.") do |vals| send(level, vals.join(" ")) end end end diff --git a/lib/puppet/parser/functions/defined.rb b/lib/puppet/parser/functions/defined.rb index 2930a65cc..90632af2f 100644 --- a/lib/puppet/parser/functions/defined.rb +++ b/lib/puppet/parser/functions/defined.rb @@ -1,27 +1,27 @@ # Test whether a given class or definition is defined Puppet::Parser::Functions::newfunction(:defined, :type => :rvalue, :doc => "Determine whether a given type is defined, either as a native type or a defined type, or whether a class is defined. This is useful for checking whether a class is defined and only including it if it is. This function can also test whether a resource has been defined, using resource references - (e.g., ``if defined(File['/tmp/myfile']) { ... }``). This function is unfortunately + (e.g., `if defined(File['/tmp/myfile']) { ... }`). This function is unfortunately dependent on the parse order of the configuration when testing whether a resource is defined.") do |vals| result = false vals = [vals] unless vals.is_a?(Array) vals.each do |val| case val when String if Puppet::Type.type(val) or find_definition(val) or find_hostclass(val) result = true break end when Puppet::Resource if findresource(val.to_s) result = true break end else raise ArgumentError, "Invalid argument of type '#{val.class}' to 'defined'" end end result end diff --git a/lib/puppet/parser/functions/file.rb b/lib/puppet/parser/functions/file.rb index 963111260..19ab9ba2e 100644 --- a/lib/puppet/parser/functions/file.rb +++ b/lib/puppet/parser/functions/file.rb @@ -1,23 +1,23 @@ # Returns the contents of a file Puppet::Parser::Functions::newfunction( :file, :type => :rvalue, - + :doc => "Return the contents of a file. Multiple files can be passed, and the first file that exists will be read in.") do |vals| ret = nil vals.each do |file| unless file =~ /^#{File::SEPARATOR}/ raise Puppet::ParseError, "Files must be fully qualified" end if FileTest.exists?(file) ret = File.read(file) break end end if ret ret else raise Puppet::ParseError, "Could not find any files from #{vals.join(", ")}" end end diff --git a/lib/puppet/parser/functions/inline_template.rb b/lib/puppet/parser/functions/inline_template.rb index 46e000383..9759ff6e1 100644 --- a/lib/puppet/parser/functions/inline_template.rb +++ b/lib/puppet/parser/functions/inline_template.rb @@ -1,20 +1,21 @@ Puppet::Parser::Functions::newfunction(:inline_template, :type => :rvalue, :doc => - "Evaluate a template string and return its value. See `the templating docs - `_ for more information. Note that - if multiple template strings are specified, their output is all concatenated - and returned as the output of the function.") do |vals| - require 'erb' + "Evaluate a template string and return its value. See + [the templating docs](http://docs.puppetlabs.com/guides/templating.html) for + more information. Note that if multiple template strings are specified, their + output is all concatenated and returned as the output of the function.") do |vals| + + require 'erb' vals.collect do |string| # Use a wrapper, so the template can't get access to the full # Scope object. wrapper = Puppet::Parser::TemplateWrapper.new(self) begin wrapper.result(string) rescue => detail raise Puppet::ParseError, "Failed to parse inline template: #{detail}" end end.join("") end diff --git a/lib/puppet/parser/functions/realize.rb b/lib/puppet/parser/functions/realize.rb index 4247b8af8..c21ccd14a 100644 --- a/lib/puppet/parser/functions/realize.rb +++ b/lib/puppet/parser/functions/realize.rb @@ -1,14 +1,14 @@ # This is just syntactic sugar for a collection, although it will generally # be a good bit faster. Puppet::Parser::Functions::newfunction(:realize, :doc => "Make a virtual object real. This is useful when you want to know the name of the virtual object and don't want to bother with a full collection. It is slightly faster than a collection, and, of course, is a bit shorter. You must pass the object using a - reference; e.g.: ``realize User[luke]``." ) do |vals| + reference; e.g.: `realize User[luke]`." ) do |vals| coll = Puppet::Parser::Collector.new(self, :nomatter, nil, nil, :virtual) vals = [vals] unless vals.is_a?(Array) coll.resources = vals.flatten compiler.add_collection(coll) end diff --git a/lib/puppet/parser/functions/regsubst.rb b/lib/puppet/parser/functions/regsubst.rb index c0aeef222..f655db7b3 100644 --- a/lib/puppet/parser/functions/regsubst.rb +++ b/lib/puppet/parser/functions/regsubst.rb @@ -1,100 +1,100 @@ module Puppet::Parser::Functions newfunction( :regsubst, :type => :rvalue, :doc => " Perform regexp replacement on a string or array of strings. -- **Parameters** (in order): +* *Parameters* (in order): -:target: The string or array of strings to operate on. If an array, the replacement will be performed on each of the elements in the array, and the return value will be an array. + _target_ The string or array of strings to operate on. If an array, the replacement will be performed on each of the elements in the array, and the return value will be an array. -:regexp: The regular expression matching the target string. If you want it anchored at the start and or end of the string, you must do that with ^ and $ yourself. + _regexp_ The regular expression matching the target string. If you want it anchored at the start and or end of the string, you must do that with ^ and $ yourself. -:replacement: Replacement string. Can contain back references to what was matched using \\0, \\1, and so on. + _replacement_ Replacement string. Can contain back references to what was matched using \\0, \\1, and so on. -:flags: Optional. String of single letter flags for how the regexp is interpreted: + _flags_ Optional. String of single letter flags for how the regexp is interpreted: - - **E** Extended regexps - - **I** Ignore case in regexps - - **M** Multiline regexps - - **G** Global replacement; all occurrences of the regexp in each target string will be replaced. Without this, only the first occurrence will be replaced. + - *E* Extended regexps + - *I* Ignore case in regexps + - *M* Multiline regexps + - *G* Global replacement; all occurrences of the regexp in each target string will be replaced. Without this, only the first occurrence will be replaced. -:lang: Optional. How to handle multibyte characters. A single-character string with the following values: + _lang_ Optional. How to handle multibyte characters. A single-character string with the following values: - - **N** None - - **E** EUC - - **S** SJIS - - **U** UTF-8 + - *N* None + - *E* EUC + - *S* SJIS + - *U* UTF-8 -- **Examples** +* *Examples* -Get the third octet from the node's IP address:: +Get the third octet from the node's IP address: - $i3 = regsubst($ipaddress,'^([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)$','\\3') + $i3 = regsubst($ipaddress,'^([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)$','\\3') -Put angle brackets around each octet in the node's IP address:: +Put angle brackets around each octet in the node's IP address: - $x = regsubst($ipaddress, '([0-9]+)', '<\\1>', 'G') + $x = regsubst($ipaddress, '([0-9]+)', '<\\1>', 'G') ") \ do |args| unless args.length.between?(3, 5) raise( Puppet::ParseError, "regsubst(): got #{args.length} arguments, expected 3 to 5") end target, regexp, replacement, flags, lang = args reflags = 0 operation = :sub if flags == nil flags = [] elsif flags.respond_to?(:split) flags = flags.split('') else raise( Puppet::ParseError, "regsubst(): bad flags parameter #{flags.class}:`#{flags}'") end flags.each do |f| case f when 'G' then operation = :gsub when 'E' then reflags |= Regexp::EXTENDED when 'I' then reflags |= Regexp::IGNORECASE when 'M' then reflags |= Regexp::MULTILINE else raise(Puppet::ParseError, "regsubst(): bad flag `#{f}'") end end begin re = Regexp.compile(regexp, reflags, lang) rescue RegexpError, TypeError raise( Puppet::ParseError, "regsubst(): Bad regular expression `#{regexp}'") end if target.respond_to?(operation) # String parameter -> string result result = target.send(operation, re, replacement) elsif target.respond_to?(:collect) and target.respond_to?(:all?) and target.all? { |e| e.respond_to?(operation) } # Array parameter -> array result result = target.collect { |e| e.send(operation, re, replacement) } else raise( Puppet::ParseError, "regsubst(): bad target #{target.class}:`#{target}'") end return result end end diff --git a/lib/puppet/parser/functions/require.rb b/lib/puppet/parser/functions/require.rb index 3f98c9523..f15046b91 100644 --- a/lib/puppet/parser/functions/require.rb +++ b/lib/puppet/parser/functions/require.rb @@ -1,58 +1,57 @@ # Requires the specified classes Puppet::Parser::Functions::newfunction( :require, :doc =>"Evaluate one or more classes, adding the required class as a dependency. The relationship metaparameters work well for specifying relationships between individual resources, but they can be clumsy for specifying relationships between classes. This function is a superset of the 'include' function, adding a class relationship so that the requiring class depends on the required class. Warning: using require in place of include can lead to unwanted dependency cycles. - For instance the following manifest, with 'require' instead of 'include' - would produce a nasty dependence cycle, because notify imposes a before - between File[/foo] and Service[foo]:: + +For instance the following manifest, with 'require' instead of 'include' would produce a nasty dependence cycle, because notify imposes a before between File[/foo] and Service[foo]: class myservice { service { foo: ensure => running } } class otherstuff { include myservice file { '/foo': notify => Service[foo] } } Note that this function only works with clients 0.25 and later, and it will fail if used with earlier clients. ") do |vals| # Verify that the 'include' function is loaded method = Puppet::Parser::Functions.function(:include) send(method, vals) if resource.metaparam_compatibility_mode? warning "The 'require' function is only compatible with clients at 0.25 and above; including class but not adding dependency" else vals = [vals] unless vals.is_a?(Array) vals.each do |klass| # lookup the class in the scopes if classobj = find_hostclass(klass) klass = classobj.name else raise Puppet::ParseError, "Could not find class #{klass}" end # This is a bit hackish, in some ways, but it's the only way # to configure a dependency that will make it to the client. # The 'obvious' way is just to add an edge in the catalog, # but that is considered a containment edge, not a dependency # edge, so it usually gets lost on the client. ref = Puppet::Resource.new(:class, klass) resource.set_parameter(:require, [resource[:require]].flatten.compact << ref) end end end diff --git a/lib/puppet/parser/functions/split.rb b/lib/puppet/parser/functions/split.rb index 5d0a9dabc..52394095a 100644 --- a/lib/puppet/parser/functions/split.rb +++ b/lib/puppet/parser/functions/split.rb @@ -1,29 +1,29 @@ module Puppet::Parser::Functions newfunction( :split, :type => :rvalue, :doc => "\ Split a string variable into an array using the specified split regexp. - Usage:: + Usage: $string = 'v1.v2:v3.v4' $array_var1 = split($string, ':') $array_var2 = split($string, '[.]') $array_var3 = split($string, '[.:]') $array_var1 now holds the result ['v1.v2', 'v3.v4'], while $array_var2 holds ['v1', 'v2:v3', 'v4'], and $array_var3 holds ['v1', 'v2', 'v3', 'v4']. Note that in the second example, we split on a string that contains a regexp meta-character (.), and that needs protection. A simple way to do that for a single character is to enclose it in square brackets.") do |args| raise Puppet::ParseError, ("split(): wrong number of arguments (#{args.length}; must be 2)") if args.length != 2 return args[0].split(Regexp.compile(args[1])) end end diff --git a/lib/puppet/parser/functions/sprintf.rb b/lib/puppet/parser/functions/sprintf.rb index 5ada0fed7..5eb4a4f9d 100644 --- a/lib/puppet/parser/functions/sprintf.rb +++ b/lib/puppet/parser/functions/sprintf.rb @@ -1,13 +1,13 @@ module Puppet::Parser::Functions newfunction( :sprintf, :type => :rvalue, :doc => "Perform printf-style formatting of text. - The first parameter is format string describing how the rest of the parameters should be formatted. See the documentation for the ``Kernel::sprintf`` function in Ruby for all the details.") do |args| + The first parameter is format string describing how the rest of the parameters should be formatted. See the documentation for the `Kernel::sprintf` function in Ruby for all the details.") do |args| raise Puppet::ParseError, 'sprintf() needs at least one argument' if args.length < 1 fmt = args.shift return sprintf(fmt, *args) end end diff --git a/lib/puppet/parser/functions/template.rb b/lib/puppet/parser/functions/template.rb index f51bcc1e2..6fa110332 100644 --- a/lib/puppet/parser/functions/template.rb +++ b/lib/puppet/parser/functions/template.rb @@ -1,22 +1,24 @@ Puppet::Parser::Functions::newfunction(:template, :type => :rvalue, :doc => - "Evaluate a template and return its value. See `the templating docs - `_ for more information. + "Evaluate a template and return its value. See + [the templating docs](http://docs.puppetlabs.com/guides/templating.html) for + more information. + Note that if multiple templates are specified, their output is all concatenated and returned as the output of the function.") do |vals| require 'erb' vals.collect do |file| # Use a wrapper, so the template can't get access to the full # Scope object. debug "Retrieving template #{file}" wrapper = Puppet::Parser::TemplateWrapper.new(self) wrapper.file = file begin wrapper.result rescue => detail raise Puppet::ParseError, "Failed to parse template #{file}: #{detail}" end end.join("") end diff --git a/lib/puppet/parser/functions/versioncmp.rb b/lib/puppet/parser/functions/versioncmp.rb index b38406532..94ba3886f 100644 --- a/lib/puppet/parser/functions/versioncmp.rb +++ b/lib/puppet/parser/functions/versioncmp.rb @@ -1,34 +1,34 @@ require 'puppet/util/package' Puppet::Parser::Functions::newfunction( :versioncmp, :type => :rvalue, - + :doc => "Compares two versions -Prototype:: +Prototype: - \$result = versioncmp(a, b) + \$result = versioncmp(a, b) - where a and b are arbitrary version strings +Where a and b are arbitrary version strings -This functions returns a number:: +This functions returns a number: - * > 0 if version a is greater than version b - * == 0 if both version are equals - * < 0 if version a is less than version b +* > 0 if version a is greater than version b +* == 0 if both version are equals +* < 0 if version a is less than version b -Example:: +Example: - if versioncmp('2.6-1', '2.4.5') > 0 { - notice('2.6-1 is > than 2.4.5') - } + if versioncmp('2.6-1', '2.4.5') > 0 { + notice('2.6-1 is > than 2.4.5') + } ") do |args| unless args.length == 2 raise Puppet::ParseError, "versioncmp should have 2 arguments" end return Puppet::Util::Package.versioncmp(args[0], args[1]) end diff --git a/lib/puppet/reference/configuration.rb b/lib/puppet/reference/configuration.rb index bfa2cb802..fadd1a423 100644 --- a/lib/puppet/reference/configuration.rb +++ b/lib/puppet/reference/configuration.rb @@ -1,146 +1,149 @@ config = Puppet::Util::Reference.newreference(:configuration, :depth => 1, :doc => "A reference for all configuration parameters") do docs = {} Puppet.settings.each do |name, object| docs[name] = object end str = "" docs.sort { |a, b| a[0].to_s <=> b[0].to_s }.each do |name, object| # Make each name an anchor header = name.to_s str += h(header, 3) # Print the doc string itself begin str += object.desc.gsub(/\n/, " ") rescue => detail puts detail.backtrace puts detail end str += "\n\n" # Now print the data about the item. str += "" val = object.default if name.to_s == "vardir" val = "/var/lib/puppet" elsif name.to_s == "confdir" val = "/etc/puppet" end # Leave out the section information; it was apparently confusing people. #str += "- **Section**: #{object.section}\n" unless val == "" - str += "- **Default**: #{val}\n" + str += "- *Default*: #{val}\n" end str += "\n" end return str end config.header = " Specifying Configuration Parameters ----------------------------------- On The Command-Line +++++++++++++++++++ -Every Puppet executable (with the exception of ``puppetdoc``) accepts all of +Every Puppet executable (with the exception of `puppetdoc`) accepts all of the parameters below, but not all of the arguments make sense for every executable. I have tried to be as thorough as possible in the descriptions of the arguments, so it should be obvious whether an argument is appropriate or not. These parameters can be supplied to the executables either as command-line options or in the configuration file. For instance, the command-line -invocation below would set the configuration directory to ``/private/puppet``:: +invocation below would set the configuration directory to `/private/puppet`: - $ puppet agent --confdir=/private/puppet + $ puppet agent --confdir=/private/puppet Note that boolean options are turned on and off with a slightly different -syntax on the command line:: +syntax on the command line: - $ puppet agent --storeconfigs + $ puppet agent --storeconfigs - $ puppet agent --no-storeconfigs + $ puppet agent --no-storeconfigs The invocations above will enable and disable, respectively, the storage of the client configuration. Configuration Files +++++++++++++++++++ + As mentioned above, the configuration parameters can also be stored in a configuration file, located in the configuration directory. As root, the -default configuration directory is ``/etc/puppet``, and as a regular user, the -default configuration directory is ``~user/.puppet``. As of 0.23.0, all -executables look for ``puppet.conf`` in their configuration directory +default configuration directory is `/etc/puppet`, and as a regular user, the +default configuration directory is `~user/.puppet`. As of 0.23.0, all +executables look for `puppet.conf` in their configuration directory (although they previously looked for separate files). For example, -``puppet.conf`` is located at ``/etc/puppet/puppet.conf`` as root and -``~user/.puppet/puppet.conf`` as a regular user by default. +`puppet.conf` is located at `/etc/puppet/puppet.conf` as `root` and +`~user/.puppet/puppet.conf` as a regular user by default. -All executables will set any parameters set within the ``main`` section, -and each executable will also use one of the ``master``, ``agent``, or -``user`` sections. +All executables will set any parameters set within the `[main]` section, +and each executable will also use one of the `[master]`, `[agent]`. File Format ''''''''''' + The file follows INI-style formatting. Here is an example of a very simple -``puppet.conf`` file:: +`puppet.conf` file: - [main] - confdir = /private/puppet - storeconfigs = true + [main] + confdir = /private/puppet + storeconfigs = true Note that boolean parameters must be explicitly specified as `true` or `false` as seen above. If you need to change file parameters (e.g., reset the mode or owner), do -so within curly braces on the same line:: +so within curly braces on the same line: - [main] - myfile = /tmp/whatever {owner = root, mode = 644} + [main] + myfile = /tmp/whatever {owner = root, mode = 644} If you're starting out with a fresh configuration, you may wish to let the executable generate a template configuration file for you by invoking the executable in question with the `--genconfig` command. The executable will print a template configuration to standard output, which can be -redirected to a file like so:: +redirected to a file like so: - $ puppet agent --genconfig > /etc/puppet/puppet.conf + $ puppet agent --genconfig > /etc/puppet/puppet.conf Note that this invocation will replace the contents of any pre-existing `puppet.conf` file, so make a backup of your present config if it contains valuable information. Like the `--genconfig` argument, the executables also accept a `--genmanifest` argument, which will generate a manifest that can be used to manage all of Puppet's directories and files and prints it to standard output. This can -likewise be redirected to a file:: +likewise be redirected to a file: - $ puppet agent --genmanifest > /etc/puppet/manifests/site.pp + $ puppet agent --genmanifest > /etc/puppet/manifests/site.pp Puppet can also create user and group accounts for itself (one `puppet` group -and one `puppet` user) if it is invoked as `root` with the `--mkusers` argument:: +and one `puppet` user) if it is invoked as `root` with the `--mkusers` argument: - $ puppet agent --mkusers + $ puppet agent --mkusers Signals ------- -The ``puppet agent`` and ``puppet master`` executables catch some signals for special -handling. Both daemons catch (``SIGHUP``), which forces the server to restart -tself. Predictably, interrupt and terminate (``SIGINT`` and ``SIGTERM``) will shut -down the server, whether it be an instance of ``puppet agent`` or ``puppet master``. -Sending the ``SIGUSR1`` signal to an instance of ``puppet agent`` will cause it to +The `puppet agent` and `puppet master` executables catch some signals for special +handling. Both daemons catch (`SIGHUP`), which forces the server to restart +tself. Predictably, interrupt and terminate (`SIGINT` and `SIGTERM`) will shut +down the server, whether it be an instance of `puppet agent` or `puppet master`. + +Sending the `SIGUSR1` signal to an instance of `puppet agent` will cause it to immediately begin a new configuration transaction with the server. This -signal has no effect on ``puppet master``. +signal has no effect on `puppet master`. Configuration Parameter Reference --------------------------------- + Below is a list of all documented parameters. Not all of them are valid with all Puppet executables, but the executables will ignore any inappropriate values. " diff --git a/lib/puppet/reference/indirection.rb b/lib/puppet/reference/indirection.rb index d14510c16..0cdbb2510 100644 --- a/lib/puppet/reference/indirection.rb +++ b/lib/puppet/reference/indirection.rb @@ -1,34 +1,33 @@ require 'puppet/indirector/indirection' require 'puppet/util/checksums' require 'puppet/file_serving/content' require 'puppet/file_serving/metadata' reference = Puppet::Util::Reference.newreference :indirection, :doc => "Indirection types and their terminus classes" do text = "" Puppet::Indirector::Indirection.instances.sort { |a,b| a.to_s <=> b.to_s }.each do |indirection| ind = Puppet::Indirector::Indirection.instance(indirection) name = indirection.to_s.capitalize text += indirection.to_s + "\n" + ("-" * name.length) + "\n\n" text += ind.doc + "\n\n" Puppet::Indirector::Terminus.terminus_classes(ind.name).sort { |a,b| a.to_s <=> b.to_s }.each do |terminus| text += terminus.to_s + "\n" + ("+" * terminus.to_s.length) + "\n\n" term_class = Puppet::Indirector::Terminus.terminus_class(ind.name, terminus) text += Puppet::Util::Docs.scrub(term_class.doc) + "\n\n" end end text end reference.header = "This is the list of all indirections, their associated terminus classes, and how you select between them. -In general, the appropriate terminus class is selected by the application for you (e.g., ``puppet agent`` would always use the ``rest`` -terminus for most of its indirected classes), but some classes are tunable via normal settings. These will have ``terminus setting`` -documentation listed with them. +In general, the appropriate terminus class is selected by the application for you (e.g., `puppet agent` would always use the `rest` +terminus for most of its indirected classes), but some classes are tunable via normal settings. These will have `terminus setting` documentation listed with them. " diff --git a/lib/puppet/reference/metaparameter.rb b/lib/puppet/reference/metaparameter.rb index 6a319f1c2..39c4b7f5f 100644 --- a/lib/puppet/reference/metaparameter.rb +++ b/lib/puppet/reference/metaparameter.rb @@ -1,48 +1,40 @@ metaparameter = Puppet::Util::Reference.newreference :metaparameter, :doc => "All Puppet metaparameters and all their details" do types = {} Puppet::Type.loadall Puppet::Type.eachtype { |type| next if type.name == :puppet next if type.name == :component types[type.name] = type } str = %{ Metaparameters -------------- Metaparameters are parameters that work with any resource type; they are part of the Puppet framework itself rather than being part of the implementation of any given instance. Thus, any defined metaparameter can be used with any instance in your manifest, including defined components. Available Metaparameters ++++++++++++++++++++++++ } begin params = [] Puppet::Type.eachmetaparam { |param| params << param } params.sort { |a,b| a.to_s <=> b.to_s }.each { |param| str += paramwrap(param.to_s, scrub(Puppet::Type.metaparamdoc(param)), :level => 4) - #puts "
#{param}
" - #puts tab(1) + Puppet::Type.metaparamdoc(param).scrub.indent($tab)gsub(/\n\s*/,' ') - #puts "
" - #puts indent(scrub(Puppet::Type.metaparamdoc(param)), $tab) - #puts scrub(Puppet::Type.metaparamdoc(param)) - #puts "
" - - #puts "" } rescue => detail puts detail.backtrace puts "incorrect metaparams: #{detail}" exit(1) end str end diff --git a/lib/puppet/reference/network.rb b/lib/puppet/reference/network.rb index 15e4f6769..fda7931fb 100644 --- a/lib/puppet/reference/network.rb +++ b/lib/puppet/reference/network.rb @@ -1,39 +1,39 @@ require 'puppet/network/handler' network = Puppet::Util::Reference.newreference :network, :depth => 2, :doc => "Available network handlers and clients" do ret = "" Puppet::Network::Handler.subclasses.sort { |a,b| a.to_s <=> b.to_s }.each do |name| handler = Puppet::Network::Handler.handler(name) next if ! handler.doc or handler.doc == "" interface = handler.interface ret += h(name, 2) ret += scrub(handler.doc) ret += "\n\n" ret += option(:prefix, interface.prefix) ret += option(:side, handler.side.to_s.capitalize) ret += option(:methods, interface.methods.collect { |ary| ary[0] }.join(", ") ) ret += "\n\n" end ret end network.header = " This is a list of all Puppet network interfaces. Each interface is implemented in the form of a client and a handler; the handler is loaded on the server, and the client knows how to call the handler's methods appropriately. Most handlers are meant to be started on the server, usually within -``puppet master``, and the clients are mostly started on the client, -usually within ``puppet agent``. +`puppet master`, and the clients are mostly started on the client, +usually within `puppet agent`. You can find the server-side handler for each interface at -``puppet/network/handler/.rb`` and the client class at -``puppet/network/client/.rb``. +`puppet/network/handler/.rb` and the client class at +`puppet/network/client/.rb`. " diff --git a/lib/puppet/reference/providers.rb b/lib/puppet/reference/providers.rb index ef33a559b..b44b26a51 100644 --- a/lib/puppet/reference/providers.rb +++ b/lib/puppet/reference/providers.rb @@ -1,123 +1,123 @@ # This doesn't get stored in trac, since it changes every time. providers = Puppet::Util::Reference.newreference :providers, :title => "Provider Suitability Report", :depth => 1, :dynamic => true, :doc => "Which providers are valid for this machine" do types = [] Puppet::Type.loadall Puppet::Type.eachtype do |klass| next unless klass.providers.length > 0 types << klass end types.sort! { |a,b| a.name.to_s <=> b.name.to_s } command_line = Puppet::Util::CommandLine.new types.reject! { |type| ! command_line.args.include?(type.name.to_s) } unless command_line.args.empty? ret = "Details about this host:\n\n" # Throw some facts in there, so we know where the report is from. ["Ruby Version", "Puppet Version", "Operating System", "Operating System Release"].each do |label| name = label.gsub(/\s+/, '') value = Facter.value(name) ret += option(label, value) end ret += "\n" count = 1 # Produce output for each type. types.each do |type| features = type.features ret += "\n" # add a trailing newline # Now build up a table of provider suitability. headers = %w{Provider Suitable?} + features.collect { |f| f.to_s }.sort table_data = {} functional = false notes = [] begin default = type.defaultprovider.name rescue Puppet::DevError default = "none" end type.providers.sort { |a,b| a.to_s <=> b.to_s }.each do |pname| data = [] table_data[pname] = data provider = type.provider(pname) # Add the suitability note if missing = provider.suitable?(false) and missing.empty? - data << "**X**" + data << "*X*" suit = true functional = true else data << "[#{count}]_" # A pointer to the appropriate footnote suit = false end # Add a footnote with the details about why this provider is unsuitable, if that's the case unless suit details = ".. [#{count}]\n" missing.each do |test, values| case test when :exists details += " - Missing files #{values.join(", ")}\n" when :variable values.each do |name, facts| if Puppet.settings.valid?(name) details += " - Setting #{name} (currently #{Puppet.settings.value(name).inspect}) not in list #{facts.join(", ")}\n" else details += " - Fact #{name} (currently #{Facter.value(name).inspect}) not in list #{facts.join(", ")}\n" end end when :true details += " - Got #{values} true tests that should have been false\n" when :false details += " - Got #{values} false tests that should have been true\n" when :feature details += " - Missing features #{values.collect { |f| f.to_s }.join(",")}\n" end end notes << details count += 1 end # Add a note for every feature features.each do |feature| if provider.features.include?(feature) - data << "**X**" + data << "*X*" else data << "" end end end ret += h(type.name.to_s + "_", 2) ret += ".. _#{type.name}: #{"http://docs.puppetlabs.com/references/stable/type.html##{type.name}"}\n\n" ret += option("Default provider", default) ret += doctable(headers, table_data) notes.each do |note| ret += note + "\n" end ret += "\n" end ret += "\n" ret end providers.header = " Puppet resource types are usually backed by multiple implementations called ``providers``, which handle variance between platforms and tools. Different providers are suitable or unsuitable on different platforms based on things like the presence of a given tool. Here are all of the provider-backed types and their different providers. Any unmentioned types do not use providers yet. " diff --git a/lib/puppet/reference/report.rb b/lib/puppet/reference/report.rb index 481ca2dc1..47fc779ab 100644 --- a/lib/puppet/reference/report.rb +++ b/lib/puppet/reference/report.rb @@ -1,24 +1,23 @@ require 'puppet/reports' report = Puppet::Util::Reference.newreference :report, :doc => "All available transaction reports" do Puppet::Reports.reportdocs end report.header = " Puppet clients can report back to the server after each transaction. This transaction report is sent as a YAML dump of the -``Puppet::Transaction::Report`` class and includes every log message that was +`Puppet::Transaction::Report` class and includes every log message that was generated during the transaction along with as many metrics as Puppet knows how -to collect. See `ReportsAndReporting Reports and Reporting`:trac: -for more information on how to use reports. +to collect. See [Reports and Reporting](http://projects.puppetlabs.com/projects/puppet/wiki/Reports_And_Reporting) for more information on how to use reports. Currently, clients default to not sending in reports; you can enable reporting -by setting the ``report`` parameter to true. +by setting the `report` parameter to true. -To use a report, set the ``reports`` parameter on the server; multiple -reports must be comma-separated. You can also specify ``none`` to disable +To use a report, set the `reports` parameter on the server; multiple +reports must be comma-separated. You can also specify `none` to disable reports entirely. Puppet provides multiple report handlers that will process client reports: " diff --git a/lib/puppet/reference/type.rb b/lib/puppet/reference/type.rb index be8742edc..2378bb83a 100644 --- a/lib/puppet/reference/type.rb +++ b/lib/puppet/reference/type.rb @@ -1,113 +1,113 @@ type = Puppet::Util::Reference.newreference :type, :doc => "All Puppet resource types and all their details" do types = {} Puppet::Type.loadall Puppet::Type.eachtype { |type| next if type.name == :puppet next if type.name == :component types[type.name] = type } str = %{ Resource Types -------------- - The *namevar* is the parameter used to uniquely identify a type instance. This is the parameter that gets assigned when a string is provided before the colon in a type declaration. In general, only developers will need to - worry about which parameter is the ``namevar``. + worry about which parameter is the `namevar`. - In the following code:: + In the following code: - file { "/etc/passwd": - owner => root, - group => root, - mode => 644 - } + file { "/etc/passwd": + owner => root, + group => root, + mode => 644 + } - ``/etc/passwd`` is considered the title of the file object (used for things like - dependency handling), and because ``path`` is the namevar for ``file``, that - string is assigned to the ``path`` parameter. + `/etc/passwd` is considered the title of the file object (used for things like + dependency handling), and because `path` is the namevar for `file`, that + string is assigned to the `path` parameter. -- *Parameters* determine the specific configuration of the instance. They either + - *Parameters* determine the specific configuration of the instance. They either directly modify the system (internally, these are called properties) or they affect - how the instance behaves (e.g., adding a search path for ``exec`` instances or determining recursion on ``file`` instances). + how the instance behaves (e.g., adding a search path for `exec` instances or determining recursion on `file` instances). -- *Providers* provide low-level functionality for a given resource type. This is + - *Providers* provide low-level functionality for a given resource type. This is usually in the form of calling out to external commands. When required binaries are specified for providers, fully qualifed paths indicate that the binary must exist at that specific path and unqualified binaries indicate that Puppet will search for the binary using the shell path. -- *Features* are abilities that some providers might not support. You can use the list + - *Features* are abilities that some providers might not support. You can use the list of supported features to determine how a given provider can be used. Resource types define features they can use, and providers can be tested to see which features they provide. } types.sort { |a,b| a.to_s <=> b.to_s }.each { |name,type| str += " ---------------- " str += h(name, 3) str += scrub(type.doc) + "\n\n" # Handle the feature docs. if featuredocs = type.featuredocs str += h("Features", 4) str += featuredocs end docs = {} type.validproperties.sort { |a,b| a.to_s <=> b.to_s }.reject { |sname| property = type.propertybyname(sname) property.nodoc }.each { |sname| property = type.propertybyname(sname) raise "Could not retrieve property #{sname} on type #{type.name}" unless property doc = nil unless doc = property.doc $stderr.puts "No docs for #{type}[#{sname}]" next end doc = doc.dup tmp = doc tmp = scrub(tmp) docs[sname] = tmp } str += h("Parameters", 4) + "\n" type.parameters.sort { |a,b| a.to_s <=> b.to_s }.each { |name,param| #docs[name] = indent(scrub(type.paramdoc(name)), $tab) docs[name] = scrub(type.paramdoc(name)) } additional_key_attributes = type.key_attributes - [:name] docs.sort { |a, b| a[0].to_s <=> b[0].to_s }.each { |name, doc| str += paramwrap(name, doc, :namevar => additional_key_attributes.include?(name)) } str += "\n" } str end