diff options
author | david <david@f03ff2f1-f02d-0410-970d-b9634babeaa1> | 2007-08-02 09:28:47 +0000 |
---|---|---|
committer | david <david@f03ff2f1-f02d-0410-970d-b9634babeaa1> | 2007-08-02 09:28:47 +0000 |
commit | 237d7fa76533bf504bbec2a57cad7c96410688ec (patch) | |
tree | df0ce22073e80783ff0ed61b2086096554c92a8b | |
parent | d8ac4de367a04728813564f3f7ed3a365f2050bc (diff) | |
download | puppet-common-237d7fa76533bf504bbec2a57cad7c96410688ec.tar.gz puppet-common-237d7fa76533bf504bbec2a57cad7c96410688ec.tar.bz2 |
moved puppet functions to common::puppetmaster
git-svn-id: http://club.black.co.at:82/svn/manifests/trunk@154 f03ff2f1-f02d-0410-970d-b9634babeaa1
-rwxr-xr-x | files/functions/basename.rb | 7 | ||||
-rwxr-xr-x | files/functions/dirname.rb | 7 | ||||
-rw-r--r-- | files/functions/gsub.rb | 7 | ||||
-rw-r--r-- | files/functions/re_escape.rb | 7 | ||||
-rw-r--r-- | files/functions/sha1.rb | 9 | ||||
-rw-r--r-- | files/functions/slash_escape.rb | 7 | ||||
-rw-r--r-- | manifests/init.pp | 13 |
7 files changed, 57 insertions, 0 deletions
diff --git a/files/functions/basename.rb b/files/functions/basename.rb new file mode 100755 index 0000000..14f0ca0 --- /dev/null +++ b/files/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/files/functions/dirname.rb b/files/functions/dirname.rb new file mode 100755 index 0000000..3f784ac --- /dev/null +++ b/files/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/files/functions/gsub.rb b/files/functions/gsub.rb new file mode 100644 index 0000000..743a700 --- /dev/null +++ b/files/functions/gsub.rb @@ -0,0 +1,7 @@ +# generic gsub call +module Puppet::Parser::Functions + newfunction(:gsub, :type => :rvalue) do |args| + args[0].gsub(/#{args[1]}/, args[2]) + end +end + diff --git a/files/functions/re_escape.rb b/files/functions/re_escape.rb new file mode 100644 index 0000000..6e5904b --- /dev/null +++ b/files/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/files/functions/sha1.rb b/files/functions/sha1.rb new file mode 100644 index 0000000..b5aa813 --- /dev/null +++ b/files/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/files/functions/slash_escape.rb b/files/functions/slash_escape.rb new file mode 100644 index 0000000..04d3b95 --- /dev/null +++ b/files/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/manifests/init.pp b/manifests/init.pp index 141d8b2..86fe2bb 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -16,5 +16,18 @@ file { mode => 0755, owner => root, group => root; } +class common::puppetmaster { + + file { + "$rubysitedir/puppet/parser": + ensure => directory, + mode => 0755, owner => root, group => root; + "$rubysitedir/puppet/parser/functions": + source => "puppet://$servername/common/functions/", + recurse => true, purge => true, + mode => 0755, owner => root, group => root; + } +} + import "defines/*.pp" import "classes/*.pp" |