diff options
author | David Schmitt <david@schmitt.edv-bus.at> | 2007-10-06 10:11:47 +0200 |
---|---|---|
committer | David Schmitt <david@schmitt.edv-bus.at> | 2007-10-06 10:11:47 +0200 |
commit | d9a3c7617a402a19f7114d9b262d62b3a7b7b24c (patch) | |
tree | 6919d055caa886317595314fa5753a115af5e559 /plugins/puppet/parser/functions | |
parent | dbf92194b77f5545ab67a9ea83241102406b4392 (diff) |
common: remove hand made plugins install defines and use matt's plugins patch
This moves all facts and puppet plugins to the plugins/ directory of modules to
get the benefits of Matt's plugins patch, that distributes these files before
the configuration is requested. This reduces the number of configuration runs to
convergence by one.
Diffstat (limited to 'plugins/puppet/parser/functions')
-rw-r--r-- | plugins/puppet/parser/functions/basename.rb | 7 | ||||
-rw-r--r-- | plugins/puppet/parser/functions/dirname.rb | 7 | ||||
-rw-r--r-- | plugins/puppet/parser/functions/gsub.rb | 13 | ||||
-rw-r--r-- | plugins/puppet/parser/functions/re_escape.rb | 7 | ||||
-rw-r--r-- | plugins/puppet/parser/functions/sha1.rb | 9 | ||||
-rw-r--r-- | plugins/puppet/parser/functions/slash_escape.rb | 7 | ||||
-rw-r--r-- | plugins/puppet/parser/functions/split.rb | 7 |
7 files changed, 57 insertions, 0 deletions
diff --git a/plugins/puppet/parser/functions/basename.rb b/plugins/puppet/parser/functions/basename.rb new file mode 100644 index 0000000..14f0ca0 --- /dev/null +++ b/plugins/puppet/parser/functions/basename.rb @@ -0,0 +1,7 @@ +# get the basename of the given filename +module Puppet::Parser::Functions + newfunction(:basename, :type => :rvalue) do |args| + File.basename(args[0]) + end +end + diff --git a/plugins/puppet/parser/functions/dirname.rb b/plugins/puppet/parser/functions/dirname.rb new file mode 100644 index 0000000..3f784ac --- /dev/null +++ b/plugins/puppet/parser/functions/dirname.rb @@ -0,0 +1,7 @@ +# get the directory corresponding to this filename +module Puppet::Parser::Functions + newfunction(:dirname, :type => :rvalue) do |args| + File.dirname(args[0]) + end +end + diff --git a/plugins/puppet/parser/functions/gsub.rb b/plugins/puppet/parser/functions/gsub.rb new file mode 100644 index 0000000..371820f --- /dev/null +++ b/plugins/puppet/parser/functions/gsub.rb @@ -0,0 +1,13 @@ +# generic gsub call +module Puppet::Parser::Functions + newfunction(:gsub, :type => :rvalue) do |args| + if args[0].is_a?(Array) + args[0].collect do |val| + val.gsub(/#{args[1]}/, args[2]) + end + else + args[0].gsub(/#{args[1]}/, args[2]) + end + end +end + diff --git a/plugins/puppet/parser/functions/re_escape.rb b/plugins/puppet/parser/functions/re_escape.rb new file mode 100644 index 0000000..6e5904b --- /dev/null +++ b/plugins/puppet/parser/functions/re_escape.rb @@ -0,0 +1,7 @@ +# apply regexp escaping to a string +module Puppet::Parser::Functions + newfunction(:re_escape, :type => :rvalue) do |args| + Regexp.escape(args[0]) + end +end + diff --git a/plugins/puppet/parser/functions/sha1.rb b/plugins/puppet/parser/functions/sha1.rb new file mode 100644 index 0000000..b5aa813 --- /dev/null +++ b/plugins/puppet/parser/functions/sha1.rb @@ -0,0 +1,9 @@ +# return the sha1 hash +require 'digest/sha1' + +module Puppet::Parser::Functions + newfunction(:sha1, :type => :rvalue) do |args| + Digest::SHA1.hexdigest(args[0]) + end +end + diff --git a/plugins/puppet/parser/functions/slash_escape.rb b/plugins/puppet/parser/functions/slash_escape.rb new file mode 100644 index 0000000..04d3b95 --- /dev/null +++ b/plugins/puppet/parser/functions/slash_escape.rb @@ -0,0 +1,7 @@ +# escape slashes in a String +module Puppet::Parser::Functions + newfunction(:slash_escape, :type => :rvalue) do |args| + args[0].gsub(/\//, '\\/') + end +end + diff --git a/plugins/puppet/parser/functions/split.rb b/plugins/puppet/parser/functions/split.rb new file mode 100644 index 0000000..d08a40b --- /dev/null +++ b/plugins/puppet/parser/functions/split.rb @@ -0,0 +1,7 @@ +# generic split call +module Puppet::Parser::Functions + newfunction(:split, :type => :rvalue) do |args| + args[0].split(/#{args[1]}/) + end +end + |