]> gitweb.fluxo.info Git - puppet-common.git/commitdiff
RDoc-ify documentation
authorDavid Schmitt <david@dasz.at>
Tue, 9 Jun 2009 15:51:10 +0000 (17:51 +0200)
committerDavid Schmitt <david@dasz.at>
Tue, 9 Jun 2009 15:51:10 +0000 (17:51 +0200)
See http://club.black.co.at/david/puppet/doc/ for a current version of the RDoc
output.

14 files changed:
README
manifests/classes/lsb_release.pp
manifests/defines/concatenated_file.pp
manifests/defines/config_file.pp
manifests/defines/line.pp
manifests/defines/module_dir.pp
manifests/defines/module_file.pp
manifests/defines/replace.pp
plugins/puppet/parser/functions/basename.rb
plugins/puppet/parser/functions/dirname.rb
plugins/puppet/parser/functions/gsub.rb
plugins/puppet/parser/functions/prefix_with.rb
plugins/puppet/parser/functions/re_escape.rb
plugins/puppet/parser/functions/split.rb

diff --git a/README b/README
index d34d11fb72523ed3cec4c46d96ca024a87a4d385..45b01069d35cd13c1baf9c5fee758bb3b40eebdb 100644 (file)
--- a/README
+++ b/README
@@ -1,17 +1,22 @@
 
-The common module installs various functions that are required by other modules. This
-module should be installed before any of the other module.
+The common module installs various functions that are required by other
+modules. This module should be installed before any of the other module.
 
 To use this module, follow these directions:
 
-1. Your modules directory will need all the files included in this repository placed
-   under a directory called "common"
+1. Your modules directory will need all the files included in this
+   repository placed under a directory called "common"
 
 2. Add the following line to manifests/site.pp:
    
-   import "modules.pp"
+       import "modules.pp"
 
 3. Add the following line to manifests/modules.pp:
 
-   import "common"
+       import "common"
+
+
+Author::    David Schmitt (mailto:david@dasz.at)
+Copyright:: Copyright (c) 2007-2009 dasz.at OG
+License::   3-clause BSD
 
index bf9baeb5e472a8c83bfb210d94225f79ea040c0e..57450722c8d9a6f6a1fcee48466197a0de5d4b78 100644 (file)
@@ -43,7 +43,7 @@ class assert_lsbdistcodename {
 
 }
 
-# To fail the complete compilation, include this class
+# To fail the complete compilation on a missing $lsbdistcodename, include this class
 class require_lsbdistcodename inherits assert_lsbdistcodename {
        exec { "false # require_lsbdistcodename": require => Exec[require_lsbdistcodename], loglevel => err }
 }
index c7e1f21047464cda1d247949febd6a21b7423e2d..8ae855c8a81897e3100c63a76cbdbb99ab917d5e 100644 (file)
@@ -26,9 +26,9 @@ module_dir { "common/cf": }
 # Exec["concat_${name}"] if you want to force an update.
 # 
 # Usage:
-# concatenated_file { "/etc/some.conf":
-#      dir => "/etc/some.conf.d",
-# }
+#  concatenated_file { "/etc/some.conf":
+#      dir => "/etc/some.conf.d",
+#  }
 define concatenated_file (
        # where the snippets are located
        $dir = '',
index 8d93e0aa1fb401d2784fa2396e34304ef8db4f49..59208acfb093be59752e9baa9299fb1b30e92e1b 100644 (file)
@@ -5,30 +5,31 @@
 # A simple wrapper to give all configuration files common defaults.
 # 
 # Usage:
-# config_file { filename:
-#      content => "....\n",
-# }
+#  config_file { filename:
+#      content => "....\n",
+#  }
 #
 # Examples: 
 #
 # To create the file /etc/vservers/${vs_name}/context with specific
 # content:
 #
-# config_file { "/etc/vservers/${vs_name}/context":
-#              content => "${context}\n",
-#              notify => Exec["vs_restart_${vs_name}"],
-#              require => Exec["vs_create_${vs_name}"];
+#  config_file {
+#      "/etc/vservers/${vs_name}/context":
+#              content => "${context}\n",
+#              notify => Exec["vs_restart_${vs_name}"],
+#              require => Exec["vs_create_${vs_name}"];
 # }
 #
 # To create the file /etc/apache2/sites-available/munin-stats with the
 # content pulled from a template:
 #
-# config_file { "/etc/apache2/sites-available/munin-stats":
-#              content => template("apache/munin-stats"),
-#              require => Package["apache2"],
-#              notify => Exec["reload-apache2"]
-# }
-
+#  config_file {
+#              "/etc/apache2/sites-available/munin-stats":
+#              content => template("apache/munin-stats"),
+#              require => Package["apache2"],
+#              notify => Exec["reload-apache2"];
+#  }
 define config_file (
        $content = '',
        $source = '',
index fe2124d01d81e35a9d2cb36b1d6f4097757f0351..be5ec3164bbe9fae76077eba6e2518576f74ed4f 100644 (file)
@@ -2,36 +2,38 @@
 # Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
 # See LICENSE for the full license granted to you.
 
-# Ensures that a specific line is present or absent in a file. This can be very
-# brittle, since even small changes can throw this off.
+# Ensures that a specific line is present or absent in a file. This can
+# be very brittle, since even small changes can throw this off.
 #
 # If the line is not present yet, it will be appended to the file.
 # 
 # The name of the define is not used. Just keep it (globally) unique and
 # descriptive.
 #
-# Use this only for very trivial stuff.
+# Use this only for very trivial stuff. Usually replacing the whole file
+# is a more stable solution with less maintenance headaches afterwards.
 #
 # Usage:
-# line { description:
-#      file => "filename",
-#      line => "content",
-#      ensure => {absent,*present*}
-# }
+#  line {
+#      description:
+#                      file => "filename",
+#              line => "content",
+#                      ensure => {absent,*present*}
+#  }
 #
 # Example:
-# The following ensures that the line "allow ^$munin_host$" exists
-# in /etc/munin/munin-node.conf, and if there are any changes notify the service for
-# a restart
-#
-# line { allow_munin_host:
-#       file => "/etc/munin/munin-node.conf",
-#       line => "allow ^$munin_host$",
-#       ensure => present,
-#       notify => Service[munin-node],
-#       require => Package[munin-node],
-# }
+# The following ensures that the line "allow ^$munin_host$" exists in
+# /etc/munin/munin-node.conf, and if there are any changes notify the
+# service for a restart
 #
+#  line {
+#      allow_munin_host:
+#              file => "/etc/munin/munin-node.conf",
+#              line => "allow ^$munin_host$",
+#              ensure => present,
+#              notify => Service[munin-node],
+#              require => Package[munin-node];
+#  }
 define line(
        $file,
        $line,
index 712e61115eb0071354467bcb5b06e56be91212fd..5b2d340b7e96e1e1607e5b421b5b6904a8310e8b 100644 (file)
@@ -4,21 +4,17 @@
 # Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
 # See LICENSE for the full license granted to you.
 
-# Use this variable to reference the base path. Thus you are safe from any
-# changes.
-$module_dir_path = '/var/lib/puppet/modules'
-
 # A module_dir is a storage place for all the stuff a module might want to
 # store. According to the FHS, this should go to /var/lib. Since this is a part
 # of puppet, the full path is /var/lib/puppet/modules/${name}. Every module
 # should # prefix its module_dirs with its name.
 # 
 # By default, the module_dir is loaded from "puppet:///${name}/module_dir". If
-# that doesn't exist an empty directory is taken as template. The directory is
+# that doesn't exist an empty directory is taken as source. The directory is
 # purged so that modules do not have to worry about removing cruft.
 # 
 # Usage:
-# module_dir { ["common", "common/dir1", "common/dir2" ]: }
+#  module_dir { ["common", "common/dir1", "common/dir2" ]: }
 define module_dir (
                $mode = 0644,
                $owner = root,
@@ -41,3 +37,6 @@ define module_dir (
        }
 }
 
+# Use this variable to reference the base path. Thus you are safe from any
+# changes.
+$module_dir_path = '/var/lib/puppet/modules'
index 6082eff55cd72a77e6f2298b38145e064c98215e..90745891dc4ae95143ccb6f1be64ee34feb53509 100644 (file)
@@ -4,12 +4,12 @@
 # Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at>
 # See LICENSE for the full license granted to you.
 
+# Put a file into module-local storage.
+#
 # Usage:
-# module_file { "module/file":
-#              source => "puppet://..",
-#              mode   => 644,   # default
-#              owner  => root,  # default
-#              group  => root,  # default
+#  module_file {
+#      "module/file":
+#                      source => "puppet://..",
 # }
 define module_file (
                $source,
index a7a59b8b26bd332a102f587c6582d29d6973b5cf..c9a98bdcc9e098eec8475dfe06f93350f89d7ce3 100644 (file)
@@ -8,6 +8,9 @@
 # creating a template is often better than this hack.
 #
 # This define uses perl regular expressions.
+#
+# Use this only for very trivial stuff. Usually replacing the whole file is a
+# more stable solution with less maintenance headaches afterwards. 
 # 
 # Usage:
 #
 # To replace the current port in /etc/munin/munin-node.conf
 # with a new port, but only disturbing the file when needed:
 #
-# replace { set_munin_node_port:
-#      file => "/etc/munin/munin-node.conf",
-#      pattern => "^port (?!$port)[0-9]*",
-#      replacement => "port $port"
-# }  
-
+#  replace {
+#      set_munin_node_port:
+#              file => "/etc/munin/munin-node.conf",
+#              pattern => "^port (?!$port)[0-9]*",
+#              replacement => "port $port"
+#  }  
 define replace($file, $pattern, $replacement) {
        $pattern_no_slashes = regsubst($pattern, '/', '\\/', 'G', 'U')
        $replacement_no_slashes = regsubst($replacement, '/', '\\/', 'G', 'U')
index 226d6e5912d768809039d27703682beb6becd371..dc72537529f823fbd93cabb60cdfd90562df3dc0 100644 (file)
@@ -1,9 +1,15 @@
-# basename(string) : string
-# basename(string[]) : string[]
+# This function has two modes of operation:
+#
+#  basename(string) : string
 #
 # Returns the last component of the filename given as argument, which must be
-# formed using forward slashes (``/..) regardless of the separator used on the
+# formed using forward slashes ("/") regardless of the separator used on the
 # local file system.
+#
+#  basename(string[]) : string[]
+#
+# Returns an array of strings with the basename of each item from the argument.
+#
 module Puppet::Parser::Functions
        newfunction(:basename, :type => :rvalue) do |args|
                if args[0].is_a?(Array)
index 44b4a00746481942ff3eb8ee4f0de15c5c00af18..ea0d50b4fa16f0041948f2797aa6b0588f943ceb 100644 (file)
@@ -1,9 +1,15 @@
-# dirname(string) : string
-# dirname(string[]) : string[]
+# This function has two modes of operation:
+# 
+#  dirname(string) : string
 #
 # Returns all components of the filename given as argument except the last
 # one. The filename must be formed using forward slashes (``/..) regardless of
 # the separator used on the local file system.
+#
+#  dirname(string[]) : string[]
+#
+# Returns an array of strings with the basename of each item from the argument. 
+#
 module Puppet::Parser::Functions
        newfunction(:dirname, :type => :rvalue) do |args|
                if args[0].is_a?(Array)
index e2410ffbadf6e7a93fbf7960540048f58fa96c9b..27e6192d2354e886693a9f338189d962fe8666e9 100644 (file)
@@ -1,9 +1,13 @@
+#
+# A thin wrapper around the ruby gsub function.
+# 
+#  gsub($string, $pattern, $replacement)
+#
+# will replace all occurrences of $pattern in $string with $replacement.
+# $string can be either a single value or an array. In the latter case, each
+# element of the array will be processed in turn.
+#
 module Puppet::Parser::Functions
-       # thin wrapper around the ruby gsub function
-       # gsub($string, $pattern, $replacement) will replace all occurrences of
-       # $pattern in $string with $replacement. $string can be either a singel
-       # value or an array. In the latter case, each element of the array will
-       # be processed in turn.
        newfunction(:gsub, :type => :rvalue) do |args|
                if args[0].is_a?(Array)
                        args[0].collect do |val|
index 6e64a4a8e36f6fabbb179070fb93a36491524931..5a12986cdf8e1c55cfe6e3f986a1021744694754 100644 (file)
@@ -1,5 +1,15 @@
-# prefix arguments 2..n with first argument
-
+# Prefixes arguments 2..n with first argument.
+#
+#  prefix_with(string prefix, string[] arguments) : string[]
+#
+# Example:
+#
+#  prefix_with("php-", [ "blah", "foo" ])
+#
+# will result in this array:
+#
+#  [ "php-blah", "php-foo" ]
+#
 module Puppet::Parser::Functions
        newfunction(:prefix_with, :type => :rvalue) do |args|
                prefix = args.shift
index 6e5904ba3ac40c77661f6df9c5dc765723150a41..7bee90a852ea54bd7497dd283f86329bfcdfb182 100644 (file)
@@ -1,4 +1,4 @@
-# apply regexp escaping to a string
+# apply ruby regexp escaping to a string
 module Puppet::Parser::Functions
        newfunction(:re_escape, :type => :rvalue) do |args|
                Regexp.escape(args[0])
index 5237c9203bbf6f744beed737916a489878184569..bffecc150d0050272fd9c7466ee6586b09769d6c 100644 (file)
@@ -1,9 +1,15 @@
-# split($string, $delimiter) : $string
-# split($string[], $delimiter) : $string[][]
+# This function has two modes of operation: 
 #
-# Split the first argument(s) on every $delimiter. $delimiter is interpreted as
+#  split($string, $delimiter) : $string
+#
+# Split the first argument on every $delimiter. $delimiter is interpreted as
 # Ruby regular expression.
 #
+#  split($string[], $delimiter) : $string[][]
+#
+# Returns an array of split results with the result of applying split to each
+# item from the first argument. 
+#
 # For long-term portability it is recommended to refrain from using Ruby's
 # extended RE features.
 module Puppet::Parser::Functions