From d9a3c7617a402a19f7114d9b262d62b3a7b7b24c Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Sat, 6 Oct 2007 10:11:47 +0200 Subject: 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. --- files/functions/basename.rb | 7 ----- files/functions/dirname.rb | 7 ----- files/functions/gsub.rb | 13 -------- files/functions/re_escape.rb | 7 ----- files/functions/sha1.rb | 9 ------ files/functions/slash_escape.rb | 7 ----- files/functions/split.rb | 7 ----- manifests/defines/puppet_install.pp | 41 ------------------------- manifests/init.pp | 12 -------- plugins/puppet/parser/functions/basename.rb | 7 +++++ plugins/puppet/parser/functions/dirname.rb | 7 +++++ plugins/puppet/parser/functions/gsub.rb | 13 ++++++++ plugins/puppet/parser/functions/re_escape.rb | 7 +++++ plugins/puppet/parser/functions/sha1.rb | 9 ++++++ plugins/puppet/parser/functions/slash_escape.rb | 7 +++++ plugins/puppet/parser/functions/split.rb | 7 +++++ 16 files changed, 57 insertions(+), 110 deletions(-) delete mode 100755 files/functions/basename.rb delete mode 100755 files/functions/dirname.rb delete mode 100644 files/functions/gsub.rb delete mode 100644 files/functions/re_escape.rb delete mode 100644 files/functions/sha1.rb delete mode 100644 files/functions/slash_escape.rb delete mode 100755 files/functions/split.rb delete mode 100644 manifests/defines/puppet_install.pp create mode 100644 plugins/puppet/parser/functions/basename.rb create mode 100644 plugins/puppet/parser/functions/dirname.rb create mode 100644 plugins/puppet/parser/functions/gsub.rb create mode 100644 plugins/puppet/parser/functions/re_escape.rb create mode 100644 plugins/puppet/parser/functions/sha1.rb create mode 100644 plugins/puppet/parser/functions/slash_escape.rb create mode 100644 plugins/puppet/parser/functions/split.rb diff --git a/files/functions/basename.rb b/files/functions/basename.rb deleted file mode 100755 index 14f0ca0..0000000 --- a/files/functions/basename.rb +++ /dev/null @@ -1,7 +0,0 @@ -# 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 deleted file mode 100755 index 3f784ac..0000000 --- a/files/functions/dirname.rb +++ /dev/null @@ -1,7 +0,0 @@ -# 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 deleted file mode 100644 index 371820f..0000000 --- a/files/functions/gsub.rb +++ /dev/null @@ -1,13 +0,0 @@ -# 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/files/functions/re_escape.rb b/files/functions/re_escape.rb deleted file mode 100644 index 6e5904b..0000000 --- a/files/functions/re_escape.rb +++ /dev/null @@ -1,7 +0,0 @@ -# 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 deleted file mode 100644 index b5aa813..0000000 --- a/files/functions/sha1.rb +++ /dev/null @@ -1,9 +0,0 @@ -# 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 deleted file mode 100644 index 04d3b95..0000000 --- a/files/functions/slash_escape.rb +++ /dev/null @@ -1,7 +0,0 @@ -# escape slashes in a String -module Puppet::Parser::Functions - newfunction(:slash_escape, :type => :rvalue) do |args| - args[0].gsub(/\//, '\\/') - end -end - diff --git a/files/functions/split.rb b/files/functions/split.rb deleted file mode 100755 index d08a40b..0000000 --- a/files/functions/split.rb +++ /dev/null @@ -1,7 +0,0 @@ -# generic split call -module Puppet::Parser::Functions - newfunction(:split, :type => :rvalue) do |args| - args[0].split(/#{args[1]}/) - end -end - diff --git a/manifests/defines/puppet_install.pp b/manifests/defines/puppet_install.pp deleted file mode 100644 index dbc9848..0000000 --- a/manifests/defines/puppet_install.pp +++ /dev/null @@ -1,41 +0,0 @@ -# puppet_install.pp -- install puppet functions and facter facts -# Copyright (C) 2007 David Schmitt -# See LICENSE for the full license granted to you. - -# prepare directories to drop various puppet enhancements -file { - [ - "${rubysitedir}", - "${rubysitedir}/facter", - "${rubysitedir}/puppet", - "${rubysitedir}/puppet/provider", - "${rubysitedir}/puppet/provider/user", - "${rubysitedir}/puppet/provider/group" - ]: - ensure => directory, - mode => 0755, owner => root, group => root, -} - -define puppet::function($source) { - file { - "${rubysitedir}/puppet/parser/functions/${name}.rb": - source => $source, - mode => 755, owner => root, group => root, - } -} - -define puppet::fact($source) { - file { - "${rubysitedir}/facter/${name}.rb": - source => $source, - mode => 755, owner => root, group => root, - } -} - -define puppet::provider($source) { - file { - "${rubysitedir}/puppet/provider/${name}.rb": - source => $source, - mode => 755, owner => root, group => root, - } -} diff --git a/manifests/init.pp b/manifests/init.pp index bdaaee2..577b0c6 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -12,17 +12,5 @@ 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" 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 + -- cgit v1.2.3