I have created a custom function that I'm trying to use in my manifest.
When I use the function I get the following error message on my client.
Error: Could not retrieve catalog from remote server: Error 400 on SERVER:
wrong argument type Class (expected Module) at
/etc/puppet/manifests/nodes.pp:18 on node fubar
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
I have tested my function on server with a simple manifest locally and the
function works properly. The function I’ve created was to pad the contents
of a variable with tabs so when the variable is used in a configuration it
will have the proper alignments for readability. Below is my function,
I’ve removed parameter checking to simplify the code for troubleshooting.
module Puppet::Parser::Functions
newfunction(:talign, :type => :rvalue, :doc => <<-EOS
Pads a string with tabs for alignment purposes.
*Examples:*
taligh(‘abcd’,24,8)
Will return:
abcd\t\t
EOS
) do |arguments|
value = arguments[0]
space = arguments[1]
if arguments.size == 2
tabsize = 8
else
tabsize = arguments[2]
end
size = space.to_i - value.length
if size <= 0
result = value + "\t"
else
count = size / tabsize.to_i
while count > 0 do
value = value + "\t"
count = count - 1
end
result = value
end
return result
end
end
Here is the code that I’ve added to my manifest for testing.
$temp = talign('abc',24,8)
notify{"${temp}":}
Thanks,
Michael
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/puppet-users/-/vSdin1p-ziwJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.