# generic gsub call
module Puppet::Parser::Functions
newfunction(:gsub, :type => :rvalue) do |args|
- args[0].gsub(/#{args[1]}/, args[2])
+ 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
--- /dev/null
+# generic split call
+module Puppet::Parser::Functions
+ newfunction(:split, :type => :rvalue) do |args|
+ args[0].split(/#{args[1]}/)
+ end
+end
+
}
# if there is a header or footer file, add it
- $additional_cmd = "$header$footer" ? { '' => '', default => "| cat '${header}' - '${footer}' " }
+ $additional_cmd = "$header" ? {
+ '' => $footer ? {
+ '' => '',
+ default => "| cat - '${footer}' "
+ },
+ default => $footer ? {
+ '' => "| cat '${header}' - ",
+ default => "| cat '${header}' - '${footer}' "
+ }
+ }
# use >| to force clobbering the target file
exec { "/usr/bin/find ${dir} -maxdepth 1 -type f ! -name '*puppettmp' -print0 | sort -z | xargs -0 cat ${header_cmd} >| ${name}.puppettmp":